Milan Jain
Milan Jain

Reputation: 519

How to change the font size of yticklabels in HeatMap MATLAB?

I am trying to generate a heatmap in MATLAB but unable to change the font size of the yticklabels. I am unable to find a function through which I can set the font-size of the whole object.

I tried to set font size of the whole figure using:

set(gca, 'fontsize', 18)

However, this is also not working. Following is the code and the generated figure.

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

Upvotes: 2

Views: 1110

Answers (1)

EBH
EBH

Reputation: 10440

There is no simple and straightforward way to do that. But it's not so complicated.

First, make all figure handles visible, so you can access all properties:

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

Next, get the handle to the axes of the heat map:

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

Now, you can change what you want:

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

Upvotes: 3

Related Questions