I'm trying to create plot with solid circles in the legend. Please see the image below for what I've got so far:
I'm unable to get my legend right, ideally I would like to draw solid red circle with label Maxima and solid blue circle with label Minima. However, I'm not sure how to create solid circles in legend.
Please see my code below:
\begin{tikzpicture}
\begin{axis}[
trig format plots=rad,
axis lines = middle,
enlargelimits,
clip=false,
legend entries={Minima,Maxima}
]
\addplot[domain=-2*pi:2*pi,samples=200,black] {sin(x)};
\fill[red] (axis cs: 0.5*pi,1.0) circle[radius=3pt];
\fill[red] (axis cs: -1.5*pi,1.0) circle[radius=3pt];
\fill[blue] (axis cs: -0.5*pi,-1.0) circle[radius=3pt];
\fill[blue] (axis cs: 1.5*pi,-1.0) circle[radius=3pt];
\draw[dotted,red!80] (axis cs: -1.5*pi,1.1) -- (axis cs: -1.5*pi,0);
\draw[dotted,red!80] (axis cs: 0.5*pi,1.1) -- (axis cs: 0.5*pi,0);
\draw[dotted,blue!80] (axis cs: 1.5*pi,-1.1) -- (axis cs: 1.5*pi,0.0);
\draw[dotted,blue!80] (axis cs: -0.5*pi,-1.1) -- (axis cs: -0.5*pi,0.0);
\addlegendimage{mark=ball,ball color=red,draw=red}
\addlegendimage{mark=ball,ball color=blue,draw=blue}
\end{axis}
\end{tikzpicture}
Any help or suggestions would be greatly appreciated.
Best Answer
For this simple case, you can fake it