How to change XColor and YColor in heatmap plot?
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Cris LaPierre
2020 年 12 月 12 日
編集済み: Cris LaPierre
2020 年 12 月 12 日
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 件のコメント
Cris LaPierre
2020 年 12 月 12 日
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.
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

