Menu

#201 [legend] order of legend entries is strange/wrong when `transposed legend` is used

v1.0 (example)
open
legend (2)
2
2018-02-22
2018-02-22
No

As was shown in https://tex.stackexchange.com/q/416614 it seems that legend transposed does not do the right thing if not all \addplot commands have a corresponding \legend entry.

Here I add another example when transposing fails.

% used PGFPlots v1.15
\documentclass[border=1pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        legend columns=2,
        transpose legend,
        legend pos=north west,
        cycle multiindex* list={
            color list\nextlist
            mark list*\nextlist
        },
    ]
        \addplot {x};       %\addlegendentry{A}
        \addplot {2*x};     %\addlegendentry{B}
        \addplot {3*x};     %\addlegendentry{C}
        \addplot {4*x};     %\addlegendentry{D}
        \addplot {5*x};     %\addlegendentry{E}
        \addplot {6*x};     %\addlegendentry{F}
        \addplot {7*x};     %\addlegendentry{G}

        \legend{
            \strut $A$,,%    <-- added a second comma
%            \strut $B$,
            \strut $C$,
            \strut $D$,
            \strut $E$,
            \strut $F$,
            \strut $G$,
        }
    \end{axis}
\end{tikzpicture}
\end{document}
1 Attachments

Discussion