Set default fontsize in figures

132 次查看(过去 30 天)
Anthony Amorosi
Anthony Amorosi 2020-11-25
回答: Abhishek 2025-2-7
Hello,
I am trying to setup a startup file with default parameters so that all my figures are consistent (same fonstize, linewidth, interpreter, etc). Everythings work fine except for the fontsize!
I would like the fontsize of the ticks on the x- and y-axis to be sligthly smaller than the label and legend fontsize. I used the following command in my sartup.m file:
set(groot, ...
'defaultAxesFontSize',14, ...
'defaultTextFontSize',20, ...
'defaultLegendFontSize',20, ...
)
It usually works when I manually use those lines (with gca and not groot) after every figure. But here, 'defaultAxesFontSize' sets the fontsize of all of the figure, it seems that 'defaultTextFontSize' and 'defaultLegendFontSize' do not change anything to the figure (even if I put the fontsize to 40 or higher).
Do anyone know why it does not work ? Thanks !
Anthony.

回答(1 个)

Abhishek
Abhishek 2025-2-7
Hi Anthony,
I understand you want to customize the default font sizes for axes, text, and legends for all the MATLAB figures using the “startup.m file. For MATLAB R2014b and onwards, the desired result can be achieved using the below statement in the startup.m” file:
set(groot, ...
'defaultAxesFontSize',14, ...
'defaultTextFontSize',20, ...
'defaultTextFontSizeMode','manual' ...
'defaultLegendFontSize',32, ...
'defaultLegendFontSizeMode','manual' ...
)
Please refer to following already existing answer which explains about the solution in detail:

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by