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

조회 수: 8 (최근 30일)
ercan duzgun
ercan duzgun 2022년 2월 25일
댓글: Voss 2022년 2월 25일
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
ercan duzgun
ercan duzgun 2022년 2월 25일
@_ Thank you very much.
Voss
Voss 2022년 2월 25일
@ercan duzgun You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (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