# Series of vertical bar plots from table data

I'm trying to achieve something a little ambitious and I'm stuck with how to manipulate table data with pgfplots and pgfplotstable.

I have a data file with benchmark results of a number of different tools among a certain number of different data sets. The file has this form:

datasets tool1 tool2 tool3 tool4 tool5 tool6
dataset1     1     2     3     4     5     6
dataset2     1     2     3     4     5     6
dataset3     1     2     3     4     5     6
dataset4     1     2     3     4     5     6
dataset5     1     2     3     4     5     6
dataset6     1     2     3     4     5     6
dataset7     1     2     3     4     5     6
dataset8     1     2     3     4     5     6


that is, the tools are placed on different columns, and the data sets on different rows. I would like to plot this data in a sort of table of the same shape, with a bar plot for each row, showing the timings of different tools on the dataset of each row.

Thus, the first column of the table should report the names of the datasets, and the second column should contain the bar plots.

The problems I have:

• How to iterate over the rows of the file to produce the table?
• I can imagine iterating with \foreach, but I have problems in obtaining a bar plot from a single given row of the file.
• How to generate a single bar plot from each single row?

I don't know how to mock my intended result. It is something like this example, with bar plots instead of those rain plots, and without hardcoding the names of the rows on the first column.

Any suggestion?

• You should look at datatool and csvsimple. Related: tex.stackexchange.com/questions/83888/… – Andrew Apr 27 '17 at 10:32
• The question does not seem to be related at all. I don't have problems plotting simple coordinates from a file. Also, I'd prefer to stay with pgfplots if possible. – gigabytes Apr 27 '17 at 10:54
• The main point here is being able to use a single line at a time to make multiple bar plots. – gigabytes Apr 27 '17 at 10:59

If your file would is named eg. mydata.csv, you can use

\pgfplotstabletranspose[colnames from=datasets,input colnames to=datasets]{\data}{mydata.csv}


Example 1:

\begin{filecontents*}{mydata.csv}
datasets tool1 tool2 tool3 tool4 tool5 tool6
dataset1     2     3     4     5     6     7
dataset2     1     2     3     4     5     6
dataset3     1     2     3     4     5     6
dataset4     1     2     3     4     5     6
dataset5     1     2     3     4     5     6
dataset6     1     2     3     4     5     6
dataset7     1     2     3     4     5     6
dataset8     1     2     3     4     5     6
\end{filecontents*}

\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.14}
\begin{document}
\pgfplotstabletranspose[colnames from=datasets,input colnames to=datasets]{\data}{mydata.csv}
\foreach \dataset in {1,...,8}{%
\begin{tikzpicture}[baseline={([yshift=-\baselineskip]p.north)}]
\begin{axis}[
height=4cm,
width=\axisdefaultwidth,
ybar,
xtick=data,
xticklabels from table={\data}{datasets},
name=p
]
\end{axis}
\end{tikzpicture}%
\par
}%
\end{document}


Example 2:

\begin{filecontents*}{mydata.csv}
datasets tool1 tool2 tool3 tool4 tool5 tool6
dataset1     2     3     4     5     6     7
dataset2     1     2     3     4     5     6
dataset3     1     2     3     4     5     6
dataset4     1     2     3     4     5     6
dataset5     1     2     3     4     5     6
dataset6     1     2     3     4     5     6
dataset7     1     2     3     4     5     6
dataset8     1     2     3     4     5     6
\end{filecontents*}
\documentclass{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\pgfplotstabletranspose[colnames from=datasets,input colnames to=datasets]{\data}{mydata.csv}
\begin{axis}[
width=\textwidth,
ybar,
bar width=2pt,
xtick=data,
xticklabels from table={\data}{datasets},
legend pos=north west,
cycle list name=color list,
every axis plot/.append style=fill
]
\pgfplotsinvokeforeach {1,...,8}
{