pgfplots 图例:如何设置图例条目的列/行顺序?

pgfplots 图例:如何设置图例条目的列/行顺序?

默认情况下,pgfplots 似乎按行添加图例条目。但是,我绘制了一个图例,其中我想添加一个两列图例(16 条曲线),并且将前 8 个条目添加到第一列,然后再开始第二列。Gnuplot 默认具有此行为,但我无法像在 pgfplots 中那样控制图例样式。我的代码如下所示。有人能帮助我吗?

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

相关内容