标签: datatipfunction

如何在MATLAB中使用TeX/LaTeX格式化自定义数据提示?

我试图用一个标有'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
Run Code Online (Sandbox Code Playgroud)

其中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)]};
Run Code Online (Sandbox Code Playgroud)

matlab latex symbols datatipfunction string-formatting

5
推荐指数
1
解决办法
2156
查看次数