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!
