【发布时间】:2023-04-05 09:34:01
【问题描述】:
我正在尝试使用标有“R:...,Theta:...”的数据提示来注释极坐标图,其中 theta 实际上是希腊符号,而不是拼写出来的单词。我熟悉使用 '\theta' 生成符号的字符串格式,但在这种情况下它不起作用。有没有办法将 LaTeX 解释器应用于数据提示?到目前为止,这是我所拥有的:
f1=figure;
t=pi/4;
r=1;
polar(t,r,'.');
dcm_obj = datacursormode(f1);
set(dcm_obj,'UpdateFcn',@polarlabel)
info_struct = getCursorInfo(dcm_obj);
datacursormode on
其中polarlabel定义如下:
function txt = polarlabel(empt,event_obj)
pos = get(event_obj,'Position');
x=pos(1);
y=pos(2);
[th,r]=cart2pol(x,y);
txt = {['R: ',num2str(r)],...
['\Theta: ',num2str(th*180/pi)]};
【问题讨论】:
标签: matlab latex symbols string-formatting datatipfunction