How to definie FontSize for Ticks on Axes when printing figures to files

2 views (last 30 days)
Hi,
I'm currently working on a figure generation tool for an app I'm writing.
In that regard, I'm trying to change the size of the ticks on the axes, but every time i save the figure, the font size of the ticks changes to a default value.
Is there a way to prevent this?
Code below:
F=figure('PaperPositionMode','manual','visible',false);
AX = gca;
% PLOT SOME STUFF (omitted here, since no relevance)
F.Resize = 'off';
F.Units = 'points';
F.PaperUnits = 'points';
AX.Units = 'points';
AX.Clipping = 'on';
AX.DataAspectRatioMode = 'auto';
AX.PositionConstraint = 'innerposition';
AX.FontSizeMode = 'manual';
% CHANGE PROPERTIES OF AX AND F
AX.XAxis.FontSize = 32;
% When executing next line, the font size of the ticks on the XAxis will change back to 10.
print(F,'CurrentFigure.png','-dpng','-r0');
% Changing AX.FontSize will not solve the problem.
% Changing interpreter will not solve the issue.
% Changing renderer will not solve the issue.
Basically I've read through every single property of the figure class, the axes class and the numeric-ruler class. I can't find any option that keeps the font size of the ticks when saving the figure to a file.
If I use the exportgraphics (https://se.mathworks.com/help/matlab/ref/exportgraphics.html) function instead of the print function, the tick size stays the same. But exportgraphics crops the image, which compleatly ruins the purpose of the program in this case. So I can't use that function.
Any suggestions would be most welcome.
Regards.

Answers (1)

Jan
Jan on 8 Mar 2021
Did you try export_fig already?

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!