How to change XColor and YColor in heatmap plot?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Cris LaPierre
am 12 Dez. 2020
Bearbeitet: Cris LaPierre
am 12 Dez. 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 Kommentare
Cris LaPierre
am 12 Dez. 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.
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

