如何在HeatMap MATLAB中更改yticklabels的字体大小?

时间:2017-07-31 06:01:57

标签: matlab matlab-figure font-size heatmap figure

我正在尝试在MATLAB中生成热图,但无法更改yticklabels的字体大小。我无法找到一个函数,通过它我可以设置整个对象的字体大小。

我尝试使用以下方法设置整个数字的字体大小:

set(gca, 'fontsize', 18)

但是,这也行不通。以下是代码和生成的图。

df = randi(10,5,20);

labely = {'Room-1', 'Room-2', 'Room-3', 'Room-4', 'Room-5'};
HMobj = HeatMap(df, 'RowLabels', labely, 'Colormap', 'redbluecmap');

HMobj.addXLabel('Time of Day', 'FontSize', 18);

enter image description here

1 个答案:

答案 0 :(得分:3)

没有简单明了的方法可以做到这一点。但它并不复杂。

首先,使所有图形句柄都可见,这样您就可以访问所有属性:

set(0,'ShowHiddenHandles','on')

接下来,获取热图的轴的句柄:

h = findobj('Tag','HeatMapAxes');

现在,您可以更改所需内容:

h.YAxis.FontSize = 18

% or  if you want to set the font size of all text in the figure:
set(findall(h,'Type','Text'),'FontSize',18)

enter image description here