Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

up vote 9 down vote accepted

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

share|improve this answer

The approach of Gonzalo (using the empty legend style) works fine.

However, pgfplots also has a predefined option for the task: setting legend plot pos=none will also do the job.

This option has the values legend plot pos=left|right|none, i.e. you can also exchange the order of text labels and images.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.