# Adding curly bracket in pgfplot

A few days ago, I was trying to draw some graph to illustrate the epsilon-delta of the limit. As I am just starting to learn how to use pgfplots and tikz, I wasn't able to do it myself, nonetheless, I found what I needed here. Now I'm facing another issue I'm not yet able to solve on my own. So I'm trying to add curly bracket [see current graph below] below the interval [a-delta,a+delta] and next to the corresponding interval on the y axis and finally add a label below/next to said bracket, to name them: $V_\delta(a)$ $V_\epsilon(L)$ respectively. So the current graph looks like this (I've added the sought after modification in paint for clarification, but the labels need not be that big):

So far the code for the graph as is, is the following, with the function being defined in the preamble as \pgfmathdeclarefunction{myfunct}{1}{\pgfmathparse{sin(deg(#1)-1.3)+1.72}}:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\pgfmathdeclarefunction{myfunct}{1}{\pgfmathparse{sin(deg(#1)-1.3)+1.72}}
\begin{document}
\begin{tikzpicture}[
>=stealth, %% arrow tips
]
\begin{axis}[
axis x line=middle,
axis y line=center,
every axis x label/.style={at={(current axis.right of origin)},anchor=north},
every axis y label/.style={at={(current axis.above origin)},anchor=east},
xmin=-0.5,xmax=1.5,
ymin=-0.5,ymax=3,
xtick=\empty,
ytick=\empty,
xlabel={$x$},
ylabel={$y$},
]

%% draw the plot:

%% define some coordinates that we need later:
\def\xa{0.25}
\pgfmathsetmacro{\ya}{myfunct(\xa)}
\path (axis cs:\xa, \ya) coordinate (0);

\def\xb{0.5}
\pgfmathsetmacro{\yb}{myfunct(\xb)}
\path (axis cs:\xb, \yb) coordinate (1);

\def\xc{0.75}
\pgfmathsetmacro{\yc}{myfunct(\xc)}
\path (axis cs:\xc, \yc) coordinate (2);

\path (axis cs:0, 0) coordinate (origin);
\end{axis}

%% draw the black lines:
\tikzset{marker/.style={shorten <=-3pt,shorten >=-3pt}} %% expand the lines
\draw [marker] (origin-|0) -- (0);
\draw [marker] (origin|-0) -- (0);
\draw [marker] (origin-|1) -- (1);
\draw [marker] (origin|-1) -- (1);
\draw [marker] (origin-|2) -- (2);
\draw [marker] (origin|-2) -- (2);

%% δ, ε:
\path (origin) ++(10pt,10pt) coordinate (offset);

\draw [<->,red!50!blue] (offset-|0) -- node [above] {$\delta$} (offset-|1);
\draw [<->,red!50!blue] (offset-|1) -- node [above] {$\delta$} (offset-|2);
\node at (origin-|1) [below,yshift=-3pt,red!50!blue] {$a$};

\draw [<->,black!50!blue] (offset|-0) -- node [right] {$\epsilon$} (offset|-1);
\draw [<->,black!50!blue] (offset|-1) -- node [right] {$\epsilon$} (offset|-2);
\node at (origin|-1) [left,xshift=-3pt,black!50!blue] {$L$};

\begin{scope}[decoration={calligraphic brace, amplitude=6pt}]
\draw[thick,decorate] (current axis.south-|2) -- (current axis.south-|0)
node[midway,below=1ex]{$V_\delta(a)$};
\draw[thick,decorate] ([xshift=-2em]origin|-0) -- ([xshift=-2em]origin|-2)
node[midway,left=1ex]{$V_\epsilon(a)$};
\end{scope}
\end{tikzpicture}
\end{document}


I sort of understand what everything does, but definitely not well enough to modify it to add the desired changes. I appreciate any help, thanks !

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Commented Jan 28, 2020 at 18:02
• I understand, I'll make sure to update it. Commented Jan 28, 2020 at 18:37

One can simplify it further but this may make it harder to understand.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{tikzpicture}[
>=stealth, %% arrow tips
]
\pgfmathdeclarefunction{myfunct}{1}{\pgfmathparse{sin(deg(#1)-1.3)+1.72}}:
\begin{axis}[
axis x line=middle,
axis y line=center,
every axis x label/.style={at={(current axis.right of origin)},anchor=north},
every axis y label/.style={at={(current axis.above origin)},anchor=east},
xmin=-0.5,xmax=1.5,
ymin=-0.5,ymax=3,
xtick=\empty,
ytick=\empty,
xlabel={$x$},
ylabel={$y$},
]
%% draw the plot:
\path foreach \X [count=\Y starting from 0] in {0.25,0.5,0.75}
{ (\X,{myfunct(\X)}) coordinate (\Y)};
\path (0, 0) coordinate (origin);
\end{axis}

%% draw the black lines:
\tikzset{marker/.style={shorten <=-3pt,shorten >=-3pt}} %% expand the lines
\draw [marker] (origin-|0) -- (0);
\draw [marker] (origin|-0) -- (0);
\draw [marker] (origin-|1) -- (1);
\draw [marker] (origin|-1) -- (1);
\draw [marker] (origin-|2) -- (2);
\draw [marker] (origin|-2) -- (2);

%%
\path (origin) ++(10pt,10pt) coordinate (offset);

\draw [<->,red!50!blue] (offset-|0) -- node [above] {$\delta$} (offset-|1);
\draw [<->,red!50!blue] (offset-|1) -- node [above] {$\delta$} (offset-|2);
\node at (origin-|1) [below,yshift=-3pt,red!50!blue] {$a$};

\draw [<->,black!50!blue] (offset|-0) -- node [right] {$\varepsilon$} (offset|-1);
\draw [<->,black!50!blue] (offset|-1) -- node [right] {$\varepsilon$} (offset|-2);
\node at (origin|-1) [left,xshift=-3pt,black!50!blue] {$L$};
%
\begin{scope}[decoration={calligraphic brace, amplitude=6pt}]
\draw[thick,decorate] (current axis.south-|2) -- (current axis.south-|0)
node[midway,below=1ex]{$v_\delta(a)$};
\draw[thick,decorate] ([xshift=-2em]origin|-0) -- ([xshift=-2em]origin|-2)
node[midway,left=1ex]{$v_\varepsilon(a)$};
\end{scope}
\end{tikzpicture}
\end{document}