我有以下pgfplots
範例:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents}{datax.dat}
1,3,6
2,4,5
3,3,7
4,1,2
5,1,1
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel={$x$},ylabel={Column Data}]
% Graph column 2 versus column 0
\addplot table[x index=0,y index=2,col sep=comma] {datax.dat};
\addlegendentry{Column 3}% y index+1 since humans count from 1
% Graph column 1 versus column 0
\addplot table[x index=0,y index=1,col sep=comma] {datax.dat};
\addlegendentry{Column 2}
\end{axis}
\end{tikzpicture}
\end{document}
我想datax.dat
從文件中讀取定義的數據test.txt
,該文件位於 tex 文件本身的同一目錄中。您能幫我如何執行此操作嗎?