Heatmap font size too small in latex
Mostra commenti meno recenti
I have created a heatmap for my project and saved it as an eps file. In the figure window, the map looks fine and legible. But when I export the eps to a Latex file, the font size is too small to read. Is there any way to fix it?
Here is the image of the issue:

The code for my heatmaps are as follows:
% Heatmap for estimated ent rate from model
figure('Color',[1 1 1]);
ent_tercile = heatmap(PE_dist_ter,'Colormap',parula, 'ColorLimits',[0 100]);
ent_tercile.YDisplayLabels= {'All','Top','Middle','Bottom'};
ent_tercile.XDisplayLabels = {'Bottom','Middle','Top','All'};
ent_tercile.XLabel = 'Wealth Terciles';
ent_tercile.YLabel = 'Schooling Terciles';
ent_tercile.Title = 'Estimated entrepreneurship rate (Model)';
saveas(ent_tercile,'figures/ent_m_tercile','epsc');
% Heatmap for ent rate from data
figure('Color',[1 1 1]);
ent_tercile_d = heatmap(PE_dist_ter_d,'Colormap',parula, 'ColorLimits',[0 100]);
ent_tercile_d.YDisplayLabels= {'All','Top','Middle','Bottom'};
ent_tercile_d.XDisplayLabels = {'Bottom','Middle','Top','All'};
ent_tercile_d.XLabel = 'Wealth Terciles';
ent_tercile_d.YLabel = 'Schooling Terciles';
ent_tercile_d.Title = 'Entrepreneurship rate (Data)';
saveas(ent_tercile_d,'figures/ent_d_tercile','epsc');
6 Commenti
dpb
il 16 Lug 2021
The obvious thing to try would be to make the fontsize larger before saving...this would end up undoubtedly as a trial and error to see what gives wanted size on output.
Girija Bahety
il 16 Lug 2021
dpb
il 16 Lug 2021
Well, I'm sure adding
ent_tercile_d.FontSize=20;
will make a difference but it appears that everything that is visible in the heatmap graphics object uses the same font information so the title and everything gets proportionally bigger, too.
Does that really make no difference on a pdf output? That would be surprising.
I'm not sure what, if anything could be done after the fact to mung on the pdf object -- that's beyond my pay grade.
Girija Bahety
il 27 Lug 2021
dpb
il 27 Lug 2021
"when I export the eps file to a latex file, the font size still is small."
How do you do that operation -- do you know that the font size is "still small" in the .eps file or only in the end result? It may well be in that step, not the first in which case it may not be MATLAB's fault.
Girija Bahety
il 2 Ago 2021
Risposte (1)
Dave B
il 26 Lug 2021
0 voti
Girija -
These solutions will increase the size of all of your text, but I think that's what you're looking for. Resizing a subset of the text would be somewhat trickier.
You could try adjusting the PaperPosition property of the figure. Making smaller 'paper' might help in making the relative size of the text bigger. You can do this with set(gcf,'PaperPosition, ...) (looking at the 3rd and 4th elements to adjust width and height). Or you can play with it interactively in the Print Preview dialog box from the File menu. Note that the changes you make there should influence the export.
An alternate option, which you'll also find in the print preview dialog - there's a tab that reads "Lines/Text" which contains an option for scaling the Font Size. I'm not sure of a way to do that programatically though...
8 Commenti
dpb
il 27 Lug 2021
"These solutions will increase the size of all of your text, ..."
Indeed. This seems like a flaw in the implementation -- any other figure, even though
hAx=axes;
xlabel('X')
title('Default Title')
hAx.XAxis.Label.FontSize
ans =
11.00
>> hAx.Title.FontSize
ans =
11.00
>> hAx.LabelFontSizeMultiplier
ans =
1.10
>> hAx.TitleFontSizeMultiplier
ans =
1.10
>>
has them set to be the same size; they're different properties and so can be modified independently of each other. Why one would develop the heatmap plot and not have similar features is beyond me...
Dave
il 27 Lug 2021
dpb - I feel your pain. Standalone visualizations like heatmap don't provide the full set of axes controls, but it's clear that some of them would be really useful (others maybe not so much). These charts are trying to provide a simpler, reduced, interface...but that clearly has a cost. I can think of some workarounds here, but can definitely understand why someone would want heatmap to work more like a traditional object in an axes!
It boggles my mind why TMW has gone this route of neutering these new features, thinking they must encapsulate them and hide stuff from the mere mortals who are users. This invariablly results in stuff like this -- users are always going to want to either customize or add something that TMW designers didn't anticipate.
Why not instead build them as traditional plots with the preset features so that they're still easy to use in the base case, but not opaque to the user who wants more?
ADDENDUM
I'd add that it's precisely the new(er)/less experienced users for whom these cause the most stress and difficulty when they do want to make any changes -- the more experienced users understand about "handle diving" and finding properties for graphics objects and have at least a basic knowledge and know that underneath it all are the various handle graphics objects so that "somewhere in there" are the properties they need. The really experienced even know about Yair's undocumented godsend to find the hidden properties.
It's precisely those you're intending to protect that are most inconvenienced. All one has to do is follow the plaintive cries posted here to see the symptoms...
$0.02, imo, ymmv, etc., etc., etc., ... and in the spirit of hopefully improving user interfaces going forward.
Girija Bahety
il 2 Ago 2021
Modificato: Girija Bahety
il 2 Ago 2021
Dave B
il 2 Ago 2021
I'm not 100% sure I understand the question, but I think you're asking for:
f = gcf;
f.PaperPosition(3:4)=[3 5]
or
f = gcf;
f.PaperPosition(3:4)=f.PaperPosition(3:4) * 0.5;
or, if you really want to use set, you can use a strategy like:
set(f, 'PaperPosition', get(f, 'PaperPosition') .* [1 1 .5 .5])
Girija Bahety
il 2 Ago 2021
dpb
il 2 Ago 2021
" just want [you] to know that this is a pain that we see (and feel), and that I hope we can do better to reduce it." @Dave B
Thanks again for feedback -- it at least makes users feel much more like there is some concern even if changes are yet a long ways off -- and that perhaps can influence future to having fewer of these kinds of items being released as more consideration is given to being more open/flexible as opposed to opaque.
Categorie
Scopri di più su Data Distribution Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!