Using time derivative dot in plot legend

Hello! I would like to use the time derivative dot over a character in my legend to a plot. I have searched and no solution seems to work.
This is what i would like to do (if it where latex) \dot{\theta}_{in}
Any suggestions? Using Matlab R2014A

답변 (3개)

Kelly Kearney
Kelly Kearney 2014년 11월 25일

3 개 추천

You just need to set the interpreter after plotting:
plot(rand(10,1));
hl = legend('$\dot{\theta}_{in}$');
set(hl, 'Interpreter', 'latex');
It'll issue a warning when you first plot the legend, since it tries to use the tex renderer, but you can just ignore that.
Geoff Hayes
Geoff Hayes 2014년 11월 25일

3 개 추천

Simon - you could set the legend string using the LaTeX "code", and then change the Interpreter property of the legend to latex so that the string is interpreted appropriately. For example,
close all;
x = linspace(-2*pi,2*pi,1000);
y = sin(x);
plot(x,y);
hLeg = legend('$$sin(\theta)$$');
set(hLeg,'Interpreter','latex');
The above will plot the sine curve and display the legend text formatted as per the LaTeX string.
In your case, your legend string would be set as
hLeg = legend('$$\dot{\theta}_{in}$$');
Try the above and see what happens! (Note that the above was tested on R2014a, OS X 10.8.5.)
Andreas Wagner
Andreas Wagner 2018년 8월 15일

0 개 추천

Hi!
I also use this solution, but I would like to have the latex interpreted entries in the same font, like I didn't use the Latex interpreter. Further I have a problem, if more than one legend entry with dot. As well in the same legend I have entries which shouldn't be interpreted by 'latex':
leg=legend({'{\it \vartheta}_{W2,aus,Na.}','{\it \vartheta}_{W2,aus,ÜK}','{\it \vartheta}_{V11,ein,Na}','{\it \vartheta}_{V11,ein,ÜK}',... '$\dot{\it m}_{Sammler,aus,Na}$','$\dot{\it m}_{Sammler,aus,ÜK}$'},... 'location','northeast','fontsize',fontsizelegend); set(leg,'Interpreter','latex')
What do I have to do to create legend with the same font for all entries incuding "dot entries"?
Kind regards
Andreas Wagner

댓글 수: 1

Pa342
Pa342 2018년 9월 28일
It isn't possible and generally all the "work arounds" don't really quite work as intended. You can try putting \textsf{} around the letters e.g. legend('$\textsf{test}$') but it isn't quite correct.

댓글을 달려면 로그인하십시오.

카테고리

질문:

2014년 11월 25일

댓글:

2019년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by