How to change XColor and YColor in heatmap plot?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I want to change the color of the x- and y-axis in a heatmap plot.
Normally the following code works for a normal plot:
set(gca, 'ZColor','w', 'YColor','w', 'XColor','w') % this line does not work for heatmap
However, the indicated line does not work for heatmap as XColor etc. is not a property that works for heatmap. I get the following error:
The name 'ZColor' is not an accessible property for an instance of class 'matlab.graphics.chart.HeatmapChart'.
My question:
Is there a way to change the color of the X- and Y-axis in a heatmap to white/none?
0 commentaires
Réponses (1)
Cris LaPierre
le 12 Déc 2020
Modifié(e) : Cris LaPierre
le 12 Déc 2020
Actually, the code you share does give an error. You have to plot before you set axis color. You could also use the axis off command. Figure background color is white by default.
x = 0:0.1:10;
y = x;
plot(x,y)
axis off
A heatmap is a different type of plot. It does not have axes. Instead, you need to modify the XDisplayLabels and YDisplayLabels. There is no color or size option, so best is to set them equal to NaN. You still need a label for each row/column of the displayed data. Something like this should work.
figure
hm = rand(4);
h=heatmap(hm);
h.XDisplayLabels = nan(size(h.XDisplayData));
h.YDisplayLabels = nan(size(h.YDisplayData));
4 commentaires
Cris LaPierre
le 12 Déc 2020
If you want to show the data without a box, you might consider using imagesc instead. The rows of your matrix correspond to Y, and the columns correspond to X.
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

