# Heatmap Axis Labels Printing Vertically?

98 ビュー (過去 30 日間)
Camille Woicekowski 2020 年 6 月 25 日
コメント済み: dpb 2020 年 6 月 29 日
Quick question, the x-labels on my heatmap are showing up vertically. I can't find the reason for this. This is what I have to generate the figure
x1 = linspace(17,23.5,14)
x2 = linspace(0,16.5,34)
xx = [x1 x2]
subplot('Position',pos1);
heatmap(xx, snow_height,snow11, 'Colormap', gray)
ax = gca;
tmp = ax.XDisplayLabels;
tmp(setdiff(1:end,1:6:end)) = {''};
ax.XDisplayLabels = tmp;
and this is what is showing up. How can I get the numbers oriented properly (horizontally) on the x-axis?
##### 2 件のコメント表示非表示 1 件の古いコメント
Camille Woicekowski 2020 年 6 月 28 日
Right, that's why I added those additional lines because it was completelly illegible before since there were far too many values. So, once I have it displaying as is, is there a way to rotate the labels? I need all the columns of data displayed, and heat map requires the number of x labels (yes, labels, not just values) to be the same as the number of columns mapped, so I haven't been able to find another option for this.

サインインしてコメントする。

### 回答 (2 件)

Yair Altman 2020 年 6 月 29 日
The heatmap's X labels orientation is dynamically determined based on the number of labels and the axes width. In other words, if you make the axes wider [for example by enlarging the figure window], the X labels may change orientation from vertical to horizontal.
You can control the labes orientation programmatically as follows (undocumented):
h = heatmap(...);
s = struct(h);
s.XAxis.TickLabelRotation = 90; % vertical
s.XAxis.TickLabelRotation = 60; % angled
s.XAxis.TickLabelRotation = 0; % horizontal
Yair Altman
##### 1 件のコメント表示非表示 なし
dpb 2020 年 6 月 29 日
That's the ticket with struct! I was unaware of being able to do that.
Same thing in the end a little more directly; problem now is OP says has no effect on her plot.
But so far she hasn't provided full working example that illustrates the problem on her system to verify here.

サインインしてコメントする。

dpb 2020 年 6 月 26 日
Oh, TMW has done it again -- they've buried stuff inside opaque (to the user) objects that should be visible. I wish they would quit doing this... :(
If you don't have it, go to FEX and download Yair Altman's utility for finding hidden objects...it's the only tool readily available for such.
From it
>> hHM=heatmap(xx,hh,ss)
hHM =
HeatmapChart with properties:
XData: {48×1 cell}
YData: {100×1 cell}
ColorData: [100×48 double]
Show all properties
>> undocumented(hHM)
ans =
struct with fields:
ApplicationData: [1×1 struct]
Axes: '???'
...
DefaultPropMap_Internal: [0×0 struct]
Description: 'HeatmapChart'
DescriptionMode: 'manual'
Description_I: 'HeatmapChart'
...
MissingDataValue: '???'
NodeChildren: [3×1 Graphics]
NodeParent: [1×1 ScribeLayer]
NotUsingTableForData: '???'
...
>>
Ah!! That looks interesting--let's see what we can tell about it...
>> hHM.NodeChildren
ans =
3×1 graphics array:
ColorBar
ColorBar
Axes
>>
And we were able to find an axes object.
>> hAx=hHM.NodeChildren(3)
hAX =
Axes with properties:
XLim: [17 16.5]
YLim: [0 1]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7179 0.8150]
Units: 'normalized'
...
>>
Under it we can find and set the tick label properties including rotation...
hAx.XAxis.TickLabelRotation=0;
IMO, there's absolutely no excuse for TMW having done such stuff.
##### 12 件のコメント表示非表示 11 件の古いコメント
dpb 2020 年 6 月 29 日
Or, my address is at contact site to send privately...
But, also, you never responded to the other Q? of what various whos or other queries at command line show on your system...

サインインしてコメントする。

R2020a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by