Clarification regarding text in figure

조회 수: 1 (최근 30일)
Pankaj
Pankaj 2016년 10월 18일
댓글: dpb 2016년 10월 19일
I have a quick question:
I was trying to get text on a figure, kindly consider the following:
t = linspace(0,2*pi,50);
y = sin(t);
plot(t,y)
Following works fine
text(2, 0, '$\theta$', 'interpreter','latex','Position', [0.1 0.8], 'Units', 'normalized' );
But not this
text('$\theta$', 'interpreter','latex','Position', [0.1 0.8], 'Units', 'normalized' );
Why? Can someone please explain.
Thanks

채택된 답변

dpb
dpb 2016년 10월 18일
>> help text
text Text annotation.
text(X,Y,'string') adds the text in the quotes to location (X,Y)...
Note the X,Y inputs are not documented as optional
  댓글 수: 2
Pankaj
Pankaj 2016년 10월 19일
Thanks dpb for the reply, I could figure it out.
X and Y were provided with 'Position' property, I was missing 'String' as argument. Just add 'String' to the command.
text('String','$\theta$', 'interpreter','latex','Position', [0.1 0.8], 'Units', 'normalized' );
That works.
Screenshot form Text Properties help.
dpb
dpb 2016년 10월 19일
Yes, but the first didn't supply all properties via the named parameters in which case the X,Y implied position values must be provided.
While the above form is allowable, what's the point? It's bulkier and more error-prone as you've demonstrated than the shorthand version with only additional parameters that aren't default needing supplied...

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by