Adding labels to plots with LaTeX syntax
7 ビュー (過去 30 日間)
古いコメントを表示
I was wanting to do something like this
But I'm not sure
0 件のコメント
回答 (2 件)
Anton Kogios
2023 年 9 月 18 日
plot(0:.1:pi,sin(0:.1:pi))
text(pi/2,.9,'$$t = \frac{\pi}{2}$$', ...
'Interpreter','latex', ...
'FontSize',14, ...
'HorizontalAlignment','center')
0 件のコメント
Star Strider
2023 年 9 月 18 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Formatting and Annotation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!