Like I said in the title, I struggle with the import of data.
The experimental data, that I get, is in a .txt file and has the following structure:
xxxxxxxxxxx
yyyyyyyyyyy
zzzzzzzzzzz
N a b c
1 3 4 5
2 6 7 8
3 9 8 7
4 6 5 4
xxxxxxxxxxx
yyyyyyyyyyy
zzzzzzzzzzz
x,y and z is text that is not used in the plot, so I want to skip the lines on the top and bottom of the file – only the table is important. Right now I have to remove those lines by hand to use the code below
\documentclass[paper=a4,ngerman,xcolor=dvipsnames]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[]{pgfplots}
\usepackage[]{tikz}
\pgfplotsset{compat=1.9}
\pgfplotsset{every axis label/.append style={font=\large}}
\pgfplotsset{every tick label/.append style={font=\large}}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[]
\addplot table [y=c,x=b]{mydata.txt};
\end{axis}
\end{tikzpicture}
\end{document}
Something else I would like to know is: can i perform a simple calculation?
Because I want to plot the negative values of the row "b" from mydata.txt
For example like this:
….
\addplot table [y=c,x=g]{mydata.txt};
with g=b*(-1)
….
Best Answer
As Torbjørn T. already mentioned in his comment you can use
x expr
andy expr
to do some mathematical stuff with your table values.He also already mentioned one method where starting rows are ignored which is
skip first n
. Another method would be to assign a comment character to the lines before the actual table start, which will also work for the rows after the table. But I don't know of any key to ignore non-table lines.