Print curly braces in a plot
Show older comments
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?
Accepted Answer
More Answers (3)
Pål Næverlid Sævik
on 22 Oct 2012
7 votes
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
on 20 Sep 2011
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 Comment
Jozef Lukac
on 20 Jun 2025
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');
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!