Getting axes labels as strings

조회 수: 1 (최근 30일)
Oyeniyi
Oyeniyi 2014년 9월 9일
댓글: Star Strider 2014년 9월 9일
Is there a way to 'get' the axes label as strings instead of the default number that one receives when one uses 'get(h,'Xlabel')'. For example, if the xlabel was 'Pressure/kPa', is there a way to return this label (i.e. 'Pressure /kPa'). Many thanks.

채택된 답변

Star Strider
Star Strider 2014년 9월 9일
This works:
x = linspace(0,10*pi,1000);
y = sin(2*pi*sin(x));
figure(1)
plot(x,y)
grid
axis tight
xlabel('Furlongs/Fortnight')
xlbl = get(get(gca,'XLabel'),'String')
produces:
xlbl =
Furlongs/Fortnight
  댓글 수: 2
Oyeniyi
Oyeniyi 2014년 9월 9일
Thanks.
Star Strider
Star Strider 2014년 9월 9일
My pleasure!
The 'String' option is not prominently featured in the Axis Properties documentation. It should be.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by