How to add Geek letters within data cursor text box?

Dear all,
Hello
Any body knows how can I add Greek alphabet within a text box of Datacursor? (In an m. file, using back slash (\omega) dsiplays: Greek alphabet omega. But within a text box of Data cursor, it litteraly displays \omega !
Any ideas?

5 Comments

Is something like this what you mean?
plot(randi(10,10,1),'o')
dcm = datacursormode(gcf);
dcm.UpdateFcn = @(~,~) '\omega';
Hi Tommy
thanks for the reply,
No ,I mean:
whenever you plot a function, in the matlab f. file (figure), using 'Data Cursor' tool on the top dashboard, you can clickc at a random point and it gives you 'X' and 'Y' values. this is 'X' and 'Y' by matlab default. I need to replace 'X' with Greek letter omega (\omega). So using right click on the Datatip box >> Edit Text Update Function ; gives you the corresponding function for the datatip. in this file in line 8, you can change X to any letter you'd like BUT unfortunately it does not work for Greek alphabets. I tried '\omega' but did NOT work.
Any ideas?
I attach a copy of a sample code and the snapshots of the steps I ment above:
clc
x = linspace (0,pi/4,200)
y = sin(x)+cos(x);
figure(1)
plot(x,y)
grid on
The function which appears when you right-click on the datatip and select 'Edit Text Update Function' is the same function I access by
dcm.UpdateFcn
after I call
dcm = datacursormode;
so my comment above is really the same thing as what you are doing. Sure enough, when I follow the steps you outlined (right-click a datatip, choose to edit the update function, and change the 'X' to '\omega'), I still see the Greek symbol in my datatip.
What version of MATLAB are you running? I am using R2019a. I would guess you are using a version pre-R2018b, which is when datatips started using the TeX interpreter. The TeX interpreter will display the Greek symbols correctly.
If you run the below code, is anything displayed or do you get an error?
clc
x = linspace (0,pi/4,200);
y = sin(x)+cos(x);
figure(1)
plot(x,y)
grid on
dcm = datacursormode;
disp(get(dcm,'Interpreter'));
Hi Tommy
I think I got your point, I use Matlab R2014a, so apparently this the issue with my verison, and code is correct.
Even when I run the above code (you sent), I have error:
Error using graphics.datacursormanager/get
The name 'Interpreter' is not an accessible property for an instance of class
'datacursormanager'.
Ah ok then as far as I can tell, it seems like you won't be able to see the Greek symbols on datatips with your version. I'm not sure if you could use text() instead or maybe some other method of displaying text in figures...

Sign in to comment.

Answers (0)

Categories

Asked:

on 20 Apr 2020

Commented:

on 24 Apr 2020

Community Treasure Hunt

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

Start Hunting!