changing font size in all the elements of figures

185 vues (au cours des 30 derniers jours)
hamza hamza
hamza hamza le 10 Juin 2015
Déplacé(e) : Dyuman Joshi le 18 Juin 2025
Hello, i want to make bigger all the text in a figure ( title, xlabel, axis,....), so i wrote this line of code in the beginning of the script: set(0,'defaulttextfontsize',30) but it doesn't change anything at all. Could you help me please, how can i change the font size? thank you
  5 commentaires
Erick Oberstar
Erick Oberstar le 18 Juin 2025
this no longer works with rlocusplot Any work around?
Adam Danz
Adam Danz le 18 Juin 2025
@Erick Oberstar See my answer below.
sys = tf([2 5 1],[1 2 3]);
rlp = rlocusplot(sys);
fontsize(rlp,20,'points')

Connectez-vous pour commenter.

Réponses (3)

onewhaleid
onewhaleid le 11 Juin 2015
Modifié(e) : onewhaleid le 11 Juin 2015
I use findall to change the font size for all text in a single figure:
set(findall(gcf,'-property','FontSize'),'FontSize',12)
  4 commentaires
Walter Roberson
Walter Roberson le 3 Oct 2017
DefaultAxesFontSize is a better programming practice, but when you use set() the property names are not case sensitive.
set(0,'defaultaxisfontsize',30) or set(0, 'DefaultAxesFontSize', 30) only works for axes text created after the call to set(); it does not change the size for any existing text object, which the findall() version does change.
David Franco
David Franco le 26 Avr 2018
Works perfectly @onewhaleid. Thanks! +1

Connectez-vous pour commenter.


Adam Danz
Adam Danz le 2 Août 2024
Starting in MATAB R2022a you can use the fontsize command.
For example, to set the fontsize to 15 points for all* text in a figure fig,
fontsize(fig, 12, 'points')
Or all* text in an axes ax
fontsize(ax, 12, 'points')
Or you could increase or decrease fontsize using a scaling factor so that relative differences in font size are maintains.
fontsize(__,scale=1.2) % increase
fontsize(__,scale=0.8) % decrease
fontsize(__,'increase')
fontsize(__,'decrease')
* Some objects do not respond to the fontsize command

Walter Roberson
Walter Roberson le 11 Juin 2015

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by