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

5 次查看(过去 30 天)
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.

采纳的回答

Voss
Voss 2022-2-25
编辑:Voss 2022-2-25
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by