
Eu tenho um arquivo de dados contendo 3 colunas, X, Y e 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
Quero um gráfico que possa exibir Y(X) ou Z(X). Como eu posso fazer?
tentei
\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}
Mas a saída é sempre Y(X).
Responder1
As opções da tabela devem ir para table
palavra-chave e não para \addplot
então funciona
\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}