do not get Greek letters in a plot
8 views (last 30 days)
Show older comments
To obtain the Greek lambda I wrote the command
text(1.5,-2,texlabel('lambda'))
but it produces just lower case Latin l. What is wrong? My matlab version is 7.11.0.584 (R2010b) on Ubuntu 17.1.
Thanks in advance, K. Veselic.
0 Comments
Accepted Answer
the cyclist
on 26 Jul 2016
That code produces the greek character for me, in R2016a, on Mac OS X.
3 Comments
More Answers (2)
John BG
on 26 Jul 2016
missing '\'
From the function text introductory example
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y)
text(pi,0,'\lambda sin(\pi)')
without '\' you don't get Greek characters
Kresimir, would you please be so kind to mark my answer as ACCEPTED ANSWER?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John
0 Comments
Image Analyst
on 27 Jul 2016
There is nothing wrong or missing with the line of code per se. The reason you don't see it is that you're printing it off screen - outside the limits of the axes, which are 0-1 if you haven't set up an axes yet. To fix it, make sure that the axes include the (x,y) location you passed in to text() as the first two arguments. You can do that by calling xlim() and ylim(). Here is the fix:
text(1.5,-2,texlabel('lambda')) % Your original code.
% Set the axes limits so text will now be on screen.
xlim([0, 3]);
ylim([-3, 3]);
2 Comments
Image Analyst
on 27 Jul 2016
Actually he said he saw a vertical bar. If that is really what he saw, and he saw it in the correct on-screen location, then I think it must be some kind of bug because for me, when it's on screen it's not a vertical bar but a normal looking lambda. But I've seen weird things before like on one guy's screen that I deployed my app to all the text labels were upside down. I told it to change the renderer and that seemed to fix it - like I said, weird! The renderer also changed the colors slightly, like the same 'y' yellow color looked substantially different in the two renderers - I have no idea why.
See Also
Categories
Find more on Labels and Annotations 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!