[Tex/LaTex] PGFPLots remove the plot line in the legend

pgfplots

How can remove the plot line in the legend?

enter image description here

\documentclass[border=0.5mm,12pt]{standalone}

\usepackage{siunitx}                       % SI Package

\sisetup{%
         output-decimal-marker={,},
         table-format = 3.1%
        }

\usepackage{pgfplots}        % Grafici

\pgfplotsset{%
            mesh line legend/.style={legend image code/.code=\meshlinelegend#1},%
            /pgf/number format/use comma,%
            compat=newest,%
%            height=9cm,%
            width=12cm%
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[%
legend pos=north west,
legend cell align=left,
no markers,
xmin=-0.3,
xmax=0.3,
ymin=0,
ymax=6,
yticklabel shift=2pt,
xticklabel shift=2pt,
point meta min={-0.3},
point meta max={0.3},
]
\addplot gnuplot[
    draw=none,
    shader=interp,
    id=DoG,
    samples=1000,
    domain=-0.3:0.3,
    y domain=0:1
]{((1/(sqrt(2*pi*0.08**2)))*exp(-(x-0)**2/(2*0.08**2)))}\closedcycle;
\addlegendimage{empty legend}\addlegendentry{$\mu=27,6\si{\second}$}
\addlegendimage{empty legend}\addlegendentry{$\sigma^2=0,01\si{\second}$}
\end{axis}
\end{tikzpicture}
\end{document}

Best Answer

To remove all the indicators, you can use the option legend style={empty legend} for the axis environment (I used some other code taken from the documentation to illustrate this; the example is compilable for everyone):

\documentclass[border=0.5mm,12pt]{standalone}
\usepackage{pgfplots}        % Grafici

\begin{document}

\begin{tikzpicture}
\begin{axis}[legend style={empty legend}]
\addplot[smooth,mark=*,blue] coordinates {
(0,2)
(2,3)
(3,1)
};
\addlegendentry{Case 1}
\addplot[smooth,color=red,mark=x]
coordinates {
(0,0)
(1,1)
(2,1)
(3,2)
};
\addlegendentry{Case 2}
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

If you only want to remove the indicator for a particular plot, tou can pass the empty legend option to the particular \addplot command:

\documentclass[border=0.5mm,12pt]{standalone}
\usepackage{pgfplots}        % Grafici

\begin{document}

\begin{tikzpicture}
\begin{axis}[legend style={at={(0.92,0.25)}}]

\addplot[smooth,mark=*,blue] coordinates {
(0,2)
(2,3)
(3,1)
};
\addlegendentry{Case 1}
\addplot[smooth,color=red,mark=x,empty legend]
coordinates {
(0,0)
(1,1)
(2,1)
(3,2)
};
\addlegendentry{Case 2}
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here