필터 지우기
필터 지우기

xtick label font change affect ytick label font

조회 수: 67 (최근 30일)
Jeyoung Kim
Jeyoung Kim 2023년 9월 19일
편집: Dyuman Joshi 2023년 9월 21일
I tried to increase xtick font size.
But, it also increased ytick font size.
How do I control them independently?
ax4=subplot(4,1,4);
plot(x,Mode1_AFR,'-o',Color='k',LineWidth=1,MarkerFaceColor=[0 0 0]);
hold on;
plot(x,Mode2_AFR,'-^',Color='g',LineWidth=1,MarkerFaceColor=[0 1 0]);
hold on;
plot(x,Mode3_AFR,'-squar',Color='r',LineWidth=1, MarkerFaceColor=[1 0 0],MarkerSize=9);
xpos = -89 % (find this out from get(yl,'pos') on the desired label x-location)
yl=ylabel('AFR [--]',FontSize=12)
pos=get(yl,'Pos')
set(yl,'Pos',[xpos pos(2)+5 pos(3)])
grid on
xlim([-80 80]);
ylim([10 50]);
yticks(10:10:50);
myaxis=gca;
myaxis.XTickLabel= { } ;
yline(0);
str={'','v3','v2','v1','0','v1','v2','v3',''};
xticklabels(str);
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'fontsize',10)
xlabel({'(d)','Boost pressure sweep'},FontSize=12)

답변 (2개)

Dyuman Joshi
Dyuman Joshi 2023년 9월 19일
편집: Dyuman Joshi 2023년 9월 19일
"How do I control them independently?"
There is no particular quantity 'Tick Label Font size' you can change, however you can change (all) the text sizes of X axis and Y axis separately (that includes labels for axis and other properties as well).
x = 0:0.01:10;
y = sin(x);
figure
plot(x,y)
ax = gca;
xlabel('x')
ylabel('sin(x)')
ax.XAxis.FontSize = 10;
ax.YAxis.FontSize = 15;
  댓글 수: 2
Jeyoung Kim
Jeyoung Kim 2023년 9월 20일
Well, I want to change label and labeltick with different font size....
Dyuman Joshi
Dyuman Joshi 2023년 9월 20일
편집: Dyuman Joshi 2023년 9월 21일
"Well, I want to change label and labeltick with different font size...."
Then you can use text instead of ylabel to make the label and change the font sizes the text and tick-labels separately.

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


Steven Lord
Steven Lord 2023년 9월 19일
Changing the FontSize property of an axes does affect the font size of both the X and Y rulers. If you get the ruler you want to change from the axes you can change properties of that ruler that won't affect the properties of other rulers.
plot(1:10);
ax = gca;
% Get the X and Y rulers to modify their properties independently
X = ax.XAxis;
Y = ax.YAxis;
% Make the X axis (but not the Y axis) red
X.Color = 'r';
% Increase the font size of the Y axis (but not the X axis)
Y.FontSize = 2*Y.FontSize;
% Change the tick direction for both X and Y axis using the axes property
ax.TickDir = 'both';
See the description of the XAxis, YAxis, and ZAxis Rulers properties in the documentation for more information about how to work with the ruler objects.

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by