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

31 views (last 30 days)
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.

Answers (2)

Voss
Voss on 4 Aug 2023
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 on 4 Aug 2023
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)

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!