How can I change axis font size only in a figure?

6 visualizzazioni (ultimi 30 giorni)
I would like to change only the axis font size in a figure. How can I do this?
My code is:
clear
clc
close all
x=linspace(0,4*pi,10)
y=x.^2.*sin(x);
f1=figure
f1.Units='centimeters'
f1.Position = [30 30 100 100]/10;
f1.Name='Measured Data'
hold on
plot(x,y,'m-','LineWidth',3)
plot(x,y,'m^','MarkerSize',14,'LineWidth',3)
xlabel('seconds','FontSize',15,...
'FontWeight','bold','Color','r')
ylabel('Population','FontSize',15,...
'FontWeight','normal','Color','r')
grid on
title('x vs. t, and example plot')
legend('y','y(data points)','Location','best')
axis([min(x) max(x) min(y) max(y)])
text(2,-40,'The angle of the wheel \theta')
Then the figure is
If I write
set(gca,'XLim',[min(x) max(x)],'FontSize',20)
command, then the figure becomes:
However I want to change only x axis and y axis font size. Not others to change. How can I don this?
Thanks in advance.

Risposta accettata

Voss
Voss il 25 Feb 2022
Modificato: Voss il 25 Feb 2022
clear
clc
close all
x=linspace(0,4*pi,10);
y=x.^2.*sin(x);
f1=figure;
f1.Units='centimeters';
f1.Position = [30 30 100 100]/10;
f1.Name='Measured Data';
hold on
plot(x,y,'m-','LineWidth',3)
plot(x,y,'m^','MarkerSize',14,'LineWidth',3)
xlabel('seconds','FontSize',15,...
'FontWeight','bold','Color','r')
ylabel('Population','FontSize',15,...
'FontWeight','normal','Color','r')
grid on
title('x vs. t, and example plot')
legend('y','y(data points)','Location','best')
axis([min(x) max(x) min(y) max(y)])
text(2,-40,'The angle of the wheel \theta')
set([get(gca(),'XAxis') get(gca(),'YAxis')],'FontSize',20);
  5 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by