You're mixing up the keys for \addplot
with those for the table
directive.
Try something like:
\documentclass{article}
\usepackage{pgfplotstable}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=$x$,ylabel=$-y$]
\pgfplotstableread{inputdata.txt}\mydata;
\addplot [
color=red,
only marks,
mark=*,
mark size=0.5pt,
]
table
[
x expr=\thisrowno{0},
y expr=\thisrowno{1}*-1
] {\mydata};
\end{axis}
\end{tikzpicture}
\end{document}
Where the data file looks like:
x y
1 2
2 -1
3 0
4 2
5 3
6 6
To get other transformations such as (x,y^2)
, just supply the appropriate expression:
y expr=\thisrowno{1}^2,
There is no log
function available, as far as I know, but there is natural log so you can write
x expr=ln(\thisrowno{0}),
Also, instead of using \thisrowno
, if you have column headings in the data file (like in the example I gave above), then you can write
x expr=\thisrow{x},
y expr=\thisrow{y},
and then you don't have to worry about the exact column numbering. Or if you had a data file that looks like
input output
1 2
2 -1
3 0
4 2
5 3
6 6
You would write
x expr=\thisrow{input},
y expr=\thisrow{output},
Though in this later case, if you're not transforming the data somehow, you could just write
x=input,
y=output,
0
, so most likely you just have to change your expressions to use\thisrowno{0}
and\thisrowno{1}