I have a plot with 63 lines, only some of which I would like legend entries for. The full legend takes up half a page, and using the \ref method does not give me consistency with the surrounding plots.
I am using a very hacked and modified version of Jake's auto-legend plot (https://tex.stackexchange.com/a/24023/4621) with some auto coloring and some filled plots for confidence interval.
I have tried this with etoolbox's \ifinlist from a list created with \forcsvlist, but the legend entries that are added have the wrong coloring.
Any ideas?
Without the \ifinlist bits it works perfectly well, but I want to only add legend entries for certain lines(columns/whatever).
Here is the function that partially does the magic:
\newcommand*{\plotFileRainbowCertaintyLegendList}[5]{
\begin{tikzpicture}
\begin{axis}[
%Unboxed,
%Dates,
%twocolumn,
y tick label style={/pgf/number format/fixed},
xlabel={},
legend columns = 3,
legend style={at={(0.5,-0.1)},anchor=north},
#4
]
%By column number
\forcsvlist{\listadd\LegendList}{50,52,53,56}
%By column name
%\forcsvlist{\listadd\LegendList}{col1Name,col2Name,etc...}
\pgfplotstableread{#1}\Mod
\pgfplotstableread{#2}\ModLow
\pgfplotstableread{#3}\ModHigh
\def\WaveLow{360}
\def\WaveHigh{660}
\pgfplotstablegetcolsof{\Mod}
\pgfmathtruncatemacro\numberofcols{\pgfplotsretval-1}
\pgfmathsetmacro{\waveStep}{(\WaveHigh-\WaveLow)/\numberofcols}
\pgfplotsinvokeforeach{1,...,\numberofcols}{
\pgfmathparse{\WaveLow+##1*\waveStep}
\definecolor{Offence##1}{wave}{\pgfmathresult}
\addplot+[Offence##1!50,opacity=0.01,name path=confLow, mark = none, line width = 0, forget plot,#5] table [y index=##1] \ModLow ;
\addplot+[Offence##1!50,opacity=0.01,name path=confHigh, mark = none, line width = 0, forget plot,#5] table [y index=##1] \ModHigh ;
\addplot[Offence##1!70,opacity=0.5, forget plot,#5] fill between[of=confLow and confHigh];
\pgfplotstablegetcolumnnamebyindex{##1}\of{\Mod}\to{\colname}
\addplot+[Offence##1,solid,thick,mark=none,#5] table [y index=##1] {\Mod};
%By column number
\xifinlist{##1}{\LegendList}{\addlegendentryexpanded{\colname};}{}
}
%By column name
%\xifinlist{\colname}{\LegendList}{\addlegendentryexpanded{\colname};}{}
%}
\end{axis}
\end{tikzpicture}
}
Which produces output like:

