Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

By default, pgfplots seems to add legend entries row-wise. However, I've plot where I'd like a two-column legend (16 curves) and the first 8 entries to be added to the first column before starting the second column. Gnuplot has this behaviour by default, but I can't control the legend style as well as in pgfplots. My code is shown below. Can anyone help me?

\documentclass[landscape]{article}

\usepackage{pgfplots}

\begin{document}

\pgfplotsset{
    legend style={%
        at={(.99,0.99)},
        anchor=north east,
        legend columns=2,
        font=\footnotesize,
    },
    width=16.18cm,height=6.18cm,
    xmin=0,xmax=100.01,
    ymin=0,ymax=8,
    xtick={0,10,...,100},
    ytick={0,2,...,8},
    xlabel={\large Downstream distance, $x$/[cm]},
    ylabel={\large Height profile, $h(x,t)$/[cm]},
    grid=major,
}

\begin{tikzpicture}

\begin{axis}
\addplot gnuplot [id=p1] {07-09-14/t_0.25.dat u 1:2};
\addplot gnuplot [id=p2] {07-09-14/t_0.5.dat u 1:2};
\addplot gnuplot [id=p3] {07-09-14/t_0.75.dat u 1:2};
\addplot gnuplot [id=p4] {07-09-14/t_1.dat u 1:2};
\addplot gnuplot [id=p5] {07-09-14/t_1.25.dat u 1:2};
\addplot gnuplot [id=p6] {07-09-14/t_1.5.dat u 1:2};
\addplot gnuplot [id=p7] {07-09-14/t_1.75.dat u 1:2};
\addplot gnuplot [id=p8] {07-09-14/t_2.dat u 1:2};
\addplot gnuplot [id=p9] {07-09-14/t_2.25.dat u 1:2};
\addplot gnuplot [id=p10] {07-09-14/t_2.5.dat u 1:2};
\addplot gnuplot [id=p11] {07-09-14/t_2.75.dat u 1:2};
\addplot gnuplot [id=p12] {07-09-14/t_3.dat u 1:2};
\addplot gnuplot [id=p13] {07-09-14/t_3.25.dat u 1:2};
\addplot gnuplot [id=p14] {07-09-14/t_3.5.dat u 1:2};
\addplot gnuplot [id=p15] {07-09-14/t_3.75.dat u 1:2};
\addplot gnuplot [id=p16] {07-09-14/t_4.dat u 1:2};

\legend{{$t=0.25$ s},{$t=0.5$ s},{$t=0.75$ s},{$t=1$ s},{$t=1.25$ s},{$t=1.5$ s},{$t=1.75$ s},{$t=2$ s},{$t=2.25$ s},{$t=2.5$ s},{$t=2.75$ s},{$t=3$ s},{$t=3.25$ s},{$t=3.5$ s},{$t=3.75$ s},{$t=4$ s}};

\end{axis}

\end{tikzpicture}

\end{document}
share|improve this question

closed as too localized by percusse, Paul Gaborit, zeroth, Tom Bombadil, Claudio Fiandrino Sep 26 '12 at 16:11

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I get precisely what you described from your example. Two columns eight rows. –  percusse Jun 28 '12 at 13:31
2  
there is some transposed legend option (or something like that) which might fit your needs –  Christian Feuersänger Jun 28 '12 at 15:51
    
+1 for Christian. The exact option name is transpose legend. (page 123 of manual) –  willem Jul 1 '12 at 15:14
add comment

Browse other questions tagged or ask your own question.