Why doesn't heatmap use the default font?

2 views (last 30 days)
O.Hubert
O.Hubert on 6 Aug 2018
Commented: Adam on 6 Aug 2018
Hello,
I would like to change the font in the axes of my heatmap. I provide a MWE below. I would like the Y-axis and the X-axis to be of the same font as the default and I don't want to manually change that for every plot as that would kill the idea of having a default fontname.
I am using MATLAB R2016a, so inserting 'FontName','Latin Modern Roman' in the heatmap function will not work.
Thank you in advance, Olivier.
% Minimum (Non)-Working Example
Country={'Belgium','France','Germany'};
random_matrix=rand(3,3);
% Set default depending on your MATLAB version
set(0, 'DefaultAxesFontName', 'Latin Modern Roman');
set(0, 'defaultAxesFontName', 'Latin Modern Roman');
% Generate the heatmap
figure('Name','Distance Matrix');heatmap(random_matrix, Country, Country, [], ...
'TickAngle', 45,'ShowAllTicks', true,'Colormap', 'gray','Colorbar', true,'ColorLevels',50);
title(['Distance Matrix']); % title is changed according to new default, but not the rest of the heatmap
% Option suggested in https://nl.mathworks.com/matlabcentral/answers/221149-is-it-not-possible-to-change-every-font-size-on-plots-at-the-same-time
fig = gcf;
set( findall(fig, 'property', 'FontName'), 'FontName', 'Latin Modern Roman') % Not working
  1 Comment
Adam
Adam on 6 Aug 2018
h = heatmap( ... );
h.FontName = '...';
seems to work for me, although it seems to do some odd things to the font colour too in some cases (e.g. setting to Courier).

Sign in to comment.

Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!