# How to use \addplot with “draw = none” and marks?

I would like to record a plot's style to the legend without actually drawing the plot.

I know how to do this when the plot style does not have marks, as shown in the first example below.

However, when the plot has marks, as in the second example, the marks still get drawn even though draw=none.

Is there anyway to suppress the marks, while still ensuring that the style gets propagated to the legend? If not, any suggested workarounds?

MWE:

\documentclass[article]{standalone}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

\begin{axis}

% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry

% Would like to do the same thing with a mark
% But the mark still gets drawn!
\addplot [blue, mark=*, domain=0:3.5, draw=none] {15 - .5*x};

\end{axis}
\end{tikzpicture}
\end{document}


This produces:

What I want is a blank plot with just the legend.

You can use addlegendimage (in combination with \addlegendentry) to achieve what you want. Just give the option or key--values respectively to the commands argument as you would do to \addplot. Please note that at least one \addplot command is present so that the legend shows up.

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}

\end{axis}
\end{tikzpicture}
\end{document}


If you are willing to cheat, you could set xmin=0 and just plot samples at={-1}. I stress that this is a cheat, and of course won't work if you wan to use that empty plot for intersections or fillbetween or the like.

\documentclass[article]{standalone}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

\begin{axis}[xmin=0,xmax=3.5]

% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry