I am trying to read from a file with 100000 rows (I plot only the first 600) and 12 columns of data and to plot it with different colors. The data does not contain x components, that is why I use x expr=\coordindex in my code.
At the moment I am facing two problems with my plot.
- The different columns have the same color (black)
- The label in the legend should be
$d_1$,...,$d_{12}$instead of$d_0$,...,$d_{11}$
I tried the following code:
\documentclass[pdftex]{scrbook}
\usepackage{pgfplots,pgfplotstable}
\newcommand{\plotfile}[1]{
\pgfplotstableread{#1}{\table}
\pgfplotstablegetcolsof{#1}
\pgfmathtruncatemacro\numberofcols{\pgfplotsretval - 1}
\pgfplotsinvokeforeach{0,...,\numberofcols}{
\pgfplotstablegetcolumnnamebyindex{##1}\of{\table}\to{\colname}
\addplot[only marks, mark size=0.3pt,mark=*] table [x expr=\coordindex,y index=##1] {#1};
\addlegendentryexpanded{$d_{##1}$}
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel={Influx},
ylabel={Center of mass},
grid=major,
ymin=-1,
ymax=1,
xmin=0,
xmax=600,
legend style={
font=\footnotesize,
at={(1.3,1)},
anchor=north east}]
\plotfile{./tables/schwerpunkt_12_.0220.log}
\end{axis}
\end{tikzpicture}
\end{document}
The result I get is:

EDIT
I was able using the tip from @Jake (color list) to create my plot with 12 different colors. What is still not solved, is that i would like to add +1 to the number near d. This mean, instead of $d_0$, there should be $d_1$ and etc.
My guess is that i need to create somehow a macro that do a summation of ##1 + 1 and the result of it to place in addlegendentryexpanded{$d_{##1}$} instead of ##1
How could i do it?

\addplot+[only marks,.... If you don't use the+, the colour list is deactivated. Note, however, that the default colour list only contains four different colours, so you should try one of the othercycle list names (likecycle list name=color listorexotic). However, even then I doubt you'll be able to clearly tell the 12 series apart (12 is a lot). – Jake Feb 16 '12 at 18:24no markers), or do you want symbols (then you have to setonly marks)? Have you tried other cycle lists, as I described in my previous comment? – Jake Feb 16 '12 at 18:38only marksit will not connect the points with a line, but i didnt took into consideration the symbols... need to try – Eagle Feb 16 '12 at 18:52no markerand as you expected, it didn't do what i wanted. It used 4 colors and play with the line style by the other combinations... What about the other part of my problem,+1– Eagle Feb 16 '12 at 19:13