How can I get text in figures to display symbols?
15 views (last 30 days)
I know how to display greek letters in a plot label using xlabel and ylabel, but when I try to get other text in a figure (not on a plot) to display greek letters or other symbols it doesn't work. When I use:
uicontrol('Style','text','Units','pixels','Position',[1557 970 135 20], ...
the result that's displayed is "\lambda", not the small case greek letter. I'm also trying to display a degree symbol and the same thing happens when I use "\circ", and I have to use a * in the mean time.
Any suggestions? Thanks, Dave
More Answers (2)
Yair Altman on 14 Jul 2017
Edited: Walter Roberson on 14 Jul 2017
Perhaps this will help you: http://undocumentedmatlab.com/blog/customizing-matlab-labels
%show the 'for all' and 'beta' symbols
labelStr = '<html>∀β <b>bold</b> <i><font color="red">label</html>';
jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
[hcomponent,hcontainer] = javacomponent(jLabel,[100,100,40,20],gcf);
The idea here is to use HTML formatting to add the special characters. This is in line with Walter Roberson's answer, but would be displayed in a text label rather than a button.
As an alternative, you could set the HTML string on a button uicontrol, and then remove its border (which provides the 3D visual illusion) as explained here:
dpb on 6 Jun 2017
Unfortunately, the uicontrol objects do not expose an 'Interpreter' property as does the text object or even labels.
Unless Yair has some secret tricks on his "Undocumented Matlab" site, I think the only option would be to revert back to the text object to actually do the display if there isn't an installed font with the characters you want without resorting to TeX.