tikzpicture 中的多个数据列

tikzpicture 中的多个数据列

假设我们从 MATLAB 获得一个 .txt 数据文件 myplot.txt,它总共包含 51 列。我想按pgfplots以下方式绘制这些数据。myplot.txt 的第一列始终用于 x 轴,而第 2 列到第 51 列的每一列用于 y 轴,从绘图(第 1 列,第 2 列)开始直到绘图(第 1 列,第 51 列)。也就是说,我想在同一个绘图中绘制 50 个图形。我正在尝试使用以下代码。但是,它无法正常工作。

\documentclass{article}
\usepackage{pgfplots}
\usepackage{xcolor}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[grid=both,xmin=0,xmax=1,
xtick={0,1},
ymin=0,ymax=1,
width=7cm]
\addplot[color=black,mark=none,x index=0,y index=1] table {myplot.txt};
\addplot[color=black,mark=none,x index=0,y index=2] table {myplot.txt};
\addplot[color=black,mark=none,x index=0,y index=3] table {myplot.txt};
....
\addplot[color=black,mark=none,x index=0,y index=50] table {myplot.txt};
\end{tikzpicture}
\end{figure}

\end{document}

有人知道怎么做吗?非常感谢。

相关内容