1

While answering this question: Having problems with drawing a modulus graph in LaTeX (overleaf)

I encountered a strange problem/bug. && in a filter does not work with \addlegendentry

\documentclass[border= 1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[
    y filter/.expression={x>2&&x<4)?0:x},
    ] {x};
%\addlegendentry{test} %Does not work with &&
\end{axis}
\end{tikzpicture}
\end{document}

Linear graph with dip

The \addlegendentry in combination with the && from the filter gives this error:

Argument of \pgfkeys@sp@b has an extra }. \par l.12 \end{axis}

Changing && to || works fine. Is this a known bug or something I do not understand?

0 Answers0