how can one set the default size of font for plot?

I understand that
set(gca, 'FontSize', 6.0);
will set the default size of a plot. But I have let me say 10 plots in this Livescript. Is there any way to set the default size of a plot so that one does not need to do this for each plot?

 Accepted Answer

Experiment with: Default Property Values

6 Comments

It is the default graphics root object. See the documentation for groot for a complete description. (Before R2014b, it was simply 0. That may still work, althougn it will likely be deprecated in the future.)
set(groot,'Fontsize',6.0)
Error using matlab.ui.Root/set
Unrecognized property Fontsize for class Root.
This is not documented appropriately. Since FontSize is a text object property (my experience with MATLAB here), use:
DefaultFontSize = get(groot, 'defaultTextFontSize')
to get it, and a set call to change it.
Example —
DefaultFontSize = get(groot, 'defaultTextFontSize') % Original Value
set(groot, 'defaultTextFontSize', 6) % Set To New Value
DefaultFontSize = get(groot, 'defaultTextFontSize') % Check For New Setting
Run that to get the original value, then change it, and see the result.
I tested this with this code:
hold on
text(0.5, 0.5, 'Text')
DefaultFontSize = get(groot, 'defaultTextFontSize') % Original Value
set(groot, 'defaultTextFontSize', 6) % Set To New Value
DefaultFontSize = get(groot, 'defaultTextFontSize') % Check For New Setting
text(0.5, 0.6, 'Text')
set(groot, 'defaultTextFontSize', 10) % Reset TO Original Value
DefaultFontSize = get(groot, 'defaultTextFontSize') % Check For New Setting
text(0.5, 0.7, 'Text')
hold off
and it works.
MathWorks — It would be nice to have all this in one central documentation section.
.
set(groot, 'defaultTextFontSize', 6)
I thought I posted exactly that four days ago!

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!