I'm having trouble with a quite complex CSV file to plot with pgfplots
.
My CSV data looks like this:
01: Some;header;information;;
02: Some;header;information;;
03: Some;header;information;;
>>> more header lines going here
42: Column1;Column2;Column3;Column4;Column5
43: 0,1;230;23455;1234,3;0,01
44: 0,2;723;23457;1234,2;0,45
45: 0,3;20;1235;953345,1;0,87
46: 0,4;1233;1684;1234,0;0,99
>>> more lines with data to plot here
The line indicators are just for better comprehension and are not content of the CSV file! So to describe the file, the first 41 lines contain some header information. Line 42 contains the column names to plot. Line 43 and up contains all the data, usualy floating point data in this format: 1234,123456
. All columns are seperated by semicolon (;
).
What I need
is to specify some arbitrary columns to plot. One to use for x-axis and one for y-axis.
What I have tried so far (without any success):
\documentclass[parskip=half,final,12pt,abstracton,oneside,a4paper,bibliography=totocnumbered,numbers=noenddot,listof=totoc]{scrreprt}
% includes for graph plots
\usepackage{pgfplots}
\pgfplotsset{width=0.8\textwidth, compat=newest}
\begin{document}
\begin{figure}[h] %% TEST GRAPH {{{
\centering
\begin{tikzpicture}
\begin{axis}[
legend pos=north west,
xlabel={Some x-value \[$n$\]},
ylabel={Some y-value in [\%]},
]
\addplot +[restrict expr to domain={\coordindex}{42:97}]
table[x=Column1, y=Column5, col sep=semicolon,ignore chars={\,}]
{graphs/Complex_CSV_Data.csv};
\addlegendentry{Some Data}
\end{axis}
\end{tikzpicture}
\caption{Some Gprah}
\label{fig:Some Graph}
\end{figure} % }}}
\end{document}
LaTeX keeps telling me the following:
Package pgfplots Warning: Table
'graphs/Complex_CSV_Data.csv' has non-unique column name ''.
Only the first occurence can be accessed via column names. on input line 16.
...
! Package pgfplots Error: Sorry, could not retrieve column 'Column1' from table
'\\pgfplotstableread@filename@@table@name '. Please check spelling (or introdu
ce name aliases)..
...
! Package pgfplots Error: Sorry, the requested column number '' in table 'graph
s/Complex_CSV_Data.csv' does not exist!? Please verify you used the correct
index 0 <= i < N..
[EDIT] Solution:
See solution of Christian Feuersänger. To get the solution working I had to update my pgfplots
package. It turned out, that my pgfplots
package was outdated due to TeX Live 2013 Distribution. I solved the issue by hitting the following lines (as sudo) into console:
sudo tlmgr update --self
sudo tlmgr update pgfplots