0
\documentclass[tikz,border=13mm]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings,calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[>=stealth,declare function={f(\x)=\x^3/3-\x;}]
\begin{axis}[xmin=-2.2, xmax=2.2, ymin=-1.2, ymax=1.2]
\draw[scale=1,domain=-2.15:2.15,smooth,variable=\x,blue,thick] plot ({\x},{\x^3/3-\x});
\draw[scale=1,black,thick,rounded corners=8pt]
    (-2.1,{f(-2.05)}) to[bend right=5] (1.15,{f(1.15-0.05)}) -- plot[variable=\x,domain=1.15:2.05] (\x,{f(\x-0.05)-0.05}) --(-1-0.05,{f(-1)+0.05})--plot[variable=\x,domain=-1-0.05:-2+0.05] (\x-0.05,{f(\x)-0.05})--cycle;
            \end{axis}
    \end{tikzpicture}
\end{document}

Want to reproduce the dashed curve from the attached fig. I am facing trouble at the corners of the black curve. Please help and modify my code.

enter image description here.

3

1 Answer 1

2

This is my edit:

enter image description here

\documentclass[tikz,border=13mm]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}
\usetikzlibrary{calc}
%\pgfplotsset{ticks=none}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
>=stealth,
declare function={f(\x)=\x^3/3-\x;}
]
\begin{axis}[
name=MyAxis,
grid=major,
grid style=dotted , 
xmin=-2.2, 
xmax=2.2, 
ymin=-1.2,
ymax=1.2,
xlabel=$x\rightarrow$, ylabel={$y \rightarrow$}, 
xtick = {-2,-1,0,1,2},  xticklabels ={-2,-1,0,1,2},
ytick = {-1,-.5,0,.5,1}, yticklabels={-1,-.5,0,.5,1},  
%yticklabels=\empty,
scale=1, 
restrict y to domain=0:.4,
clip=false
]
\draw[scale=1,domain=-2.15:2.15,smooth,variable=\x,blue,thick] plot ({\x},{\x^3/3-\x});
\draw[scale=1,red,fill=red] (1, -2/3) circle (.5ex);
\draw[scale=1,red,fill=red] (-1, 2/3) circle (.5ex);
\draw[scale=1,black] (0, 0) circle (.5ex);
\draw[scale=1,red,thick,>={Stealth[round]},
postaction=decorate,
decoration={
markings,
mark=at position 0.15 with {\arrow[black]{<.<}},
mark=at position 0.4 with {\arrow[black]{<}},
mark=at position 0.65 with {\arrow[black]{<.<}},
mark=at position 0.925 with {\arrow[black]{<}},
}
] 
%(-2,{f(-2)}) --(0,{f(.96)}) --  plot\[variable=\x,domain=.96:.3479\]  (\x,{f(\x)}) -- cycle; % Gamma_0 curve
(-2,{f(-2)}) -- (1,{f(1)})-- plot[variable=\x,domain=1:2] (\x,{f(\x)})--(-1,{f(-1)})--plot[variable=\x,domain=-1:-2] (\x,{f(\x)});
\draw[dashed,scale=1,black,thick,>={Stealth[round]},
postaction=decorate,
%rounded corners=8pt,
decoration={
markings,
mark=at position 0.15 with {\arrow[black]{<.<}},
%mark=at position 0.4 with {\arrow[black]{<}},
mark=at position 0.65 with {\arrow[black]{<.<}},
%mark=at position 0.925 with {\arrow[black]{<}},
}
]
(-2.03,{f(-2)-0.05}) ..  controls (-2,-1) and (0.8,-0.9) .. (0.8,-0.9) parabola [bend pos=0,bend={(0.85,-0.9)}] (2.03,{f(2)+0.05}) ..  controls (2,1) and (-0.8,0.9) .. (-0.8,0.9) parabola[bend pos=0,bend={(-0.85,0.9)}] (-2.03,{f(-2)-0.05}) -- cycle;
\end{axis}
\end{tikzpicture}
\end{document}

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .