I'm creating grouplots for various datasets. Apart from some y-values, they all share the same x-values. In the past I used something like this to do the task:

\addplot table [x index = 0, y expr = \thisrowno{1}*10 ]{data.txt};


But re-loading the data for every single plot seems overkill to me. I already found out that I can use:

\pgfplotstableread[]{data.txt}\data


to preload and then plot with

\addplot table [x index = 0, y expr = \thisrowno{1}*10 ] from \data;


For the sake of readability I now would like to use something like

\addplot table [x = f1, y = f2 ] from \data;


like I could, if my file would look like:

f1 f2
0 0
1 2
2 4


But the headers of my file are unusable rubbish and I can't get any column names out of it. Also I need to preprocess my data with some factors, so I need \thisrowno{1} or \thisrow{f1}, do I? But I'd like to do all that in advance, before the first addplot - how can I do that?

Something like:

\pgfplotstableread[]{data.txt}\data
f1 = \thisrowno{0}*10 from \data # pseudo code
f2 = \thisrowno{1}*42 from \data # pseudo code

\addplot table [x = f1, y = f2 ] from \data;


I already tried to name my columns with

\pgfplotstableset{columns={f1,f2}}


which gave me no error, but it didn't had any effect neither.

## MWE

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{tikzpicture}

\begin{axis}
\addplot table [x index = 0, y expr = \thisrowno{1}*10 ] from \data;
\end{axis}

\end{tikzpicture}

\end{document}


and the data file data.txt

rubbish
rubbish
0 0
1 2
2 4

• I am not 100% sure if I have understood your problem right. About the "rubbish" headers: How about just commenting these and simply add a new one by hand to the (source) data file? About the preprocessing: Here I guess you should also just do it in an external tool (because this will be much faster and you only have to do it once then) or you could do it with PGFPlotsTable and then save the result to another file which you can then use for your \addplot commands. Was that approximately what you want to achieve? – Stefan Pinnow Feb 18 '17 at 14:38

You are looking for \pgfplotstablecreatecol.

\begin{filecontents*}{data.txt}
rubbish
rubbish
0 0
1 2
2 4
\end{filecontents*}

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{tikzpicture}