TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?




    legend style={%
        anchor=north east,
        legend columns=2,
    xlabel={\large Downstream distance, $x$/[cm]},
    ylabel={\large Height profile, $h(x,t)$/[cm]},


\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}};



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
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
While the question does not have a MWE, it has an example, and according to the votes on Christian Feuersaengers comment, I am not the only one who came here looking for this. (Sometimes google is just faster than going through the manual) – ted Apr 13 '15 at 13:31
I came here looking for exactly the same problem, and the option suggested by @ChristianFeuersänger helped me as well. So my suggestion is to reopen this question, as several people seem to have similar issues. – mdiener Aug 12 '15 at 13:36

Browse other questions tagged or ask your own question.