Adding labels to plots with LaTeX syntax
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I was wanting to do something like this
But I'm not sure
0 comentarios
Respuestas (2)
Anton Kogios
el 18 de Sept. de 2023
plot(0:.1:pi,sin(0:.1:pi))
text(pi/2,.9,'$$t = \frac{\pi}{2}$$', ...
'Interpreter','latex', ...
'FontSize',14, ...
'HorizontalAlignment','center')
0 comentarios
Star Strider
el 18 de Sept. de 2023
In the text call, specify 'Interpreter','latex', however the more interesting part of this was (finally) figuring out how to correctly place the annotation objects.
This combines both of them —
x = linspace(-2, 1, 250);
y = 3.5*exp(-(x+1).^2*150);
figure
plot(x, y, '--k')
ylim([-1 4])
yline(0, '-k')
text(0, 3.5, '$\it{t=0}$', 'Interpreter','latex', 'FontSize',15, 'Horiz','center')
text(-1.5, 1.75,'$\alpha\_$', 'Interpreter','latex', 'FontSize',15, 'Horiz','center')
xs = @(x,pos,xlim) pos(3)*(x-min(xl))/diff(xl)+pos(1);
ys = @(y,pos,ylim) pos(4)*(y-min(yl))/diff(yl)+pos(2);
xl = xlim;
yl = ylim;
pos = gca().Position;
xs = @(x,pos,xlim) pos(3)*(x-min(xl))/diff(xl)+pos(1); % 'x' Annotation Position Function
ys = @(y,pos,ylim) pos(4)*(y-min(yl))/diff(yl)+pos(2); % 'y' Annotation Position Function
% Qy = ys([2.5 3.5],pos,ylim)
% Qx = xs([1 1]*-1.5,pos,xlim)
annotation('arrow', xs([-1.5 -1.5],pos,xlim), ys([1.5 0],pos,ylim))
annotation('arrow', xs([-1.5 -1.5],pos,xlim), ys([2.0 3.5],pos,ylim))
I am not certain what the other curves represent, so I did not draw them.
.
0 comentarios
Ver también
Categorías
Más información sobre Formatting and Annotation 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!