Using time derivative dot in plot legend
71 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (3)
Kelly Kearney
el 25 de Nov. de 2014
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
el 25 de Nov. de 2014
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.)
1 comentario
Andreas Wagner
el 15 de Ag. de 2018
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 comentario
Pa342
el 28 de Sept. de 2018
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.
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!