Print curly braces in a plot
古いコメントを表示
Hello everyone,
I am trying draw a curly brace to indicate a distance in a plot (with some accompanying text). The brace should be "stretchable", i.e. vary its length according to a beginning and end point.
Any suggestions?
採用された回答
その他の回答 (3 件)
Pål Næverlid Sævik
2012 年 10 月 22 日
7 投票
I know this is one year old, but I had the same problem. I therefore wrote a function which plots a curly brace on the current figure. The code can be found at http://www.mathworks.com/matlabcentral/fileexchange/38716-curly-brace-annotation, or by searching Matlab File Exchange for "Curly Brace Annotation".
Sean de Wolski
2011 年 9 月 20 日
I would recommend starting by reading the tutorial in:
doc
MATLAB>User Guide>Graphics>Annotating Graphs>Adding Text Annotations to Graphs
Another idea is to use the text command and a LaTeX math mode brace and just rotate it and change the font size...
clear; clc;
x = linspace(0,2*pi,100);
y = sin(x);
figure(1); clf;
plot(x,y)
grid on;
ylim([-1.25, 1.25]);
text(2.8, 0.75, '$\{$', 'rotation', 210, 'fontsize', 40, ...
'interpreter', 'latex');
text(2.85, 0.75, 'My favorite part', 'fontsize', 14, ...
'interpreter', 'latex');
1 件のコメント
Jozef Lukac
2025 年 6 月 20 日
Latex commands \overbrace and \underbrace can be used here. They stretch the brace according to the content. The stretch can be set usting \hspace, e.g. \hspace{3cm}.
\overbrace{some base-text}^{upper annotation}
\underbrace{some base-text}_{lower annotation}
text(2.3, 0.9, '$\overbrace{\hspace{3cm}}^{}$',...
'rotation', -63, 'fontsize', 10, 'interpreter', 'latex');
カテゴリ
ヘルプ センター および File Exchange で Labels and Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
