How can I use a command inside an \addplot option? My guess is that I'd have to find the right expansion order.
The example below illustrates the problem. I'm not looking for a workaround (which I can do myself), but for something that uses the right combination of \expandafter and similar commands.
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\foreach \L/\C in {-8/Red,-4/Magenta,-2/Pink,0/Black,2/Beige,4/LightGreen,8/Green}
\addplot[smooth,domain=0:1,color=\C]{ \L*x) };
\end{axis}
\end{tikzpicture}
\end{document}

\edef\temp{\noexpand\draw ...} \temptrick described in thepgfplotsmanual works. – Torbjørn T. Sep 30 '17 at 15:10\expandafter\addplot\expandafter[\C,smooth,domain=0:1]{ \L*x) };. – Mike Sep 30 '17 at 15:31[...]and withcolor=\C. Mine only works, because the color can be given withoutcolor=. – Mike Oct 01 '17 at 02:14