how to change the font size in a plot (only for the axes numbers) for double axis figure

33 次查看(过去 30 天)
I have a problem changing axis font size of a double axis figure (i.e., plotyy). the font size is only changed for one of the axis
it is possible to change the font size of a single axis figure using the command "set(gca,'fontsize',number), what about the double axis.

回答(2 个)

Voss
Voss 2023-8-4
Rather than relying on gca(), you can use the two axes handles returned by plotyy, as in:
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
figure % new figure
ax = plotyy(x,y1,x,y2);
set(ax(1),'FontSize',6)
set(ax(2),'FontSize',16)

Daniel Bengtson
Daniel Bengtson 2023-8-4
Save the axes handle when you create the plot rather than using gca.
[AX,h1,h2] = plotyy(1:10,rand(10,1),1:10,rand(10,1));
set(AX,'fontsize',20)

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by