# PGFplots: decorating plot but not legend

Using PGFplots, I would like to apply a decoration to a plot but not to the corresponding legend entry. Is there a way to do this?

Here is an example: I'd like the legend image to be just the line, without the decoration "test".

\documentclass{standalone}

\usepackage{tikz,pgfplots}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=1.12}

\makeatletter
\tikzset{reset postactions/.code=\let\tikz@postactions\pgfutil@empty}
\makeatother
\tikzset{test decoration/.style={
postaction={
decorate,
decoration={
markings,
mark=between positions 0.5 and 1 step 10mm with {\node {test};}
}
}
}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[legend image post style={reset postactions}]
\legend{$-x$};
\end{axis}
\end{tikzpicture}
\end{document}

The reset postactions style (which is ineffective) comes from this answer. I've also tried resetting the test decoration style to empty inside legend image post style, with no effect.

A workaround could be to use forget plot and \addlegendimage.

\documentclass{standalone}

\usepackage{tikz,pgfplots}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=1.12}

\tikzset{test decoration/.style={
postaction={
decorate,
decoration={
markings,
mark=between positions 0.5 and 1 step 10mm with {\node {test};}
}
}
}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[myplot/.style={blue}]
\legend{$-x$};