
Ich habe eine Datendatei mit drei Spalten: X, Y und Z.
X Y Z
# datas from the natural movement of a robot
0.0000000e+00 3.3891017e-01 -1.3249598e-01
2.0000000e-02 3.3675858e-01 -1.3535520e-01
4.0000000e-02 3.3470984e-01 -1.3826038e-01
6.0000000e-02 3.3287897e-01 -1.4130291e-01
8.0000000e-02 3.3136947e-01 -1.4456564e-01
Ich möchte ein Diagramm, das Y(X) oder Z(X) anzeigen kann. Wie kann ich das tun?
Ich habe es versucht
\documentclass{standalone}
\usepackage{pgfplots}
% \usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{width=7cm}
\begin{axis} [title= two curves]
\addplot [blue, x=X, y=Y] table
{myfile.dat};
\addplot [red, x=X, y=Z] table
{myfile.dat};
\legend{$y(x)$,$z(x)$}
\end{axis}
\end{tikzpicture}
\end{document}
Die Ausgabe ist jedoch immer Y(X).
Antwort1
Die Tabellenoptionen sollten zum table
Schlüsselwort gehen und nicht zu, \addplot
dann funktioniert es
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\pgfplotstableread[]{
X Y Z
0.0000000e+00 3.3891017e-01 -1.3249598e-01
2.0000000e-02 3.3675858e-01 -1.3535520e-01
4.0000000e-02 3.3470984e-01 -1.3826038e-01
6.0000000e-02 3.3287897e-01 -1.4130291e-01
8.0000000e-02 3.3136947e-01 -1.4456564e-01
}\mytable
\begin{tikzpicture}
\begin{axis} [width=7cm,title= two curves]
\addplot[blue] table [x=X, y=Y] {\mytable};
\addplot[red] table [x=X, y=Z] {\mytable};
\legend{$y(x)$,$z(x)$}
\end{axis}
\end{tikzpicture}
\end{document}