Change font size for second y-axis in plotyy

조회 수: 10 (최근 30일)
martvald
martvald 2015년 12월 2일
답변: dpb 2015년 12월 2일
I use the plotyy for some work and need to change the fontsize of the lables so that it's readable in a document later. I know I can use plot browser and property editor to write the text, but i can't change the font size without changing the font size of the ticks. On the main axis I can simply click to label and change the size of the lable without affecting the size of the tick, can't seem to find how to do it with the second axis.
Thanks for help.

채택된 답변

Star Strider
Star Strider 2015년 12월 2일
This seems to work without affecting the ticks or tick labels:
t = linspace(0, 2*pi);
y1 = sin(t);
y2 = cos(t);
figure(1)
[ax, p1, p2] = plotyy(t, y1, t, y2);
ylabel(ax(1), 'sin(t)')
ylabel(ax(2), 'cos(t)', 'FontSize',20)

추가 답변 (1개)

dpb
dpb 2015년 12월 2일
[X|Y] labels inherit font size, name, etc., from the axes. To change the ylabel fontsize independently of the axes tick label sizes, save the axes handles and then the subsequent ylabel handle and modify its properties...
hAX=plotyy(.... % save the axes handles vector
hL2=ylabel(hAX(2),'Second Y');
set(hL2,'fontsize',16,'fontweight','bold','color','r') % example stuff set
You can, of course, use the named properties/values in the original call as well.

카테고리

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