Is it possible to set the default font size for shared axis labels in Tiled Layouts?

30 vues (au cours des 30 derniers jours)
Nathan Li
Nathan Li le 6 Juin 2021
Commenté : Macarena Santillan le 21 Déc 2025 à 21:06
I tried the following code, but it does not affect the font size for shared titles and axis labels in TiledChartLayout objects.
set(groot,'defaultAxesFontSize',16);
t = tiledlayout(2,1);
t.XLabel.String = 'x-axis label';
t.YLabel.String = 'y-axis label';
t.Title.String = 'title';
nexttile();
plot(1:10);
nexttile();
plot(1:10);
plot generated from above code
I also tried to set default properties for Text objects because the XLabel and YLabel properties of TiledLayoutChart objects are Text objects,
set(groot,'defaultTextFontSizeMode','manual');
set(groot,'defaultTextFontSize',16);
but these 2 lines did not affect any of the text in the example figure shown above. I double-checked default values for groot and called
reset(groot);
to make sure that no other default property values defined by me could potentially conflict with the example code shown above.
  1 commentaire
Marco Kendlbacher
Marco Kendlbacher le 23 Fév 2023
Just additionally use
set(groot,'defaultAxesFontSizeMode','manual');
with the specification of the 'defaultTextFontSizeMode' to 'manual'. Then it maybe should work fine.
So maybe
myfontsize = 16;
set(groot,'defaultAxesFontSizeMode','manual')
set(groot,'defaultTextFontSizeMode','manual')
set(groot,'defaultAxesFontSize',myfontsize)
set(groot,'defaultTextFontSize',myfontsize)
should do the trick.

Connectez-vous pour commenter.

Réponses (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 6 Juin 2021
Use this instead:
set(gca, 'FontSize', 16.0);
  1 commentaire
Macarena Santillan
Macarena Santillan le 20 Déc 2025 à 23:50
I am running into the same problem, and nothing really works. I get default font and size

Connectez-vous pour commenter.


Sulaymon Eshkabilov
Sulaymon Eshkabilov le 21 Déc 2025 à 5:15
It works as suggested in my previous answer - see this example:
x=0:10;
y1 = 2*x.^2-5*x+3;
y2 = -2*x.^2+5*x-3;
subplot(211)
plot(x,y1, 'ro--', 'LineWidth', 2)
set(gca, 'FontSize', 16.0);
xlabel('x values')
ylabel('y_1(x)')
subplot(212)
plot(x, y2, 'bd-.', "LineWidth", 1)
set(gca, 'FontSize', 11.0);
xlabel('x values')
ylabel('y_2(x)')
  1 commentaire
Macarena Santillan
Macarena Santillan le 21 Déc 2025 à 21:06
It worked, but I had to update my Matlab version from 2022b to 2025, apparently it is a bug.
title(t,'KTO-dp4', 'FontName', 'Cambria', 'FontSize', 15);
xlabel(t,'Wavenumber (cm^{-1})', 'FontName', 'Cambria', 'FontSize', 15);
ylabel(t,'Absorbance', 'FontName', 'Cambria', 'FontSize', 15);

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by