0

I have a single .csv data file, with contents alike this:

Time, Value 
0, 7.130000000000109
0, 7.634999999999309
0, 6.040000000000873
...
1, 5.5900000000001455
1, 6.0649999999996
1, 6.204999999999018
...
n, 5...
n, 6...
n, 7...

And I'm trying to plot a grouped bar-chart of this data, such that all the y-values (Value) with the same x-value (Time) are grouped.

Thus far I'm plotting using this:

\begin{tikzpicture}
\begin{axis}[ybar]
\addplot table [y=Value] {\datafile};
\end{axis}
\end{tikzpicture}

But the result is overlapping bars (rather than the bars being grouped next to one another). Overlapping Bar Charts

1

Figured my data was regular; m readings for each unique Time value, so I ended up doing this:

\begin{tikzpicture}
\begin{axis}[ybar]
\foreach \n in {1,...,m} {
    \addplot+[each nth point=10, filter discard warning=false,
              unbounded coords=discard, color={blue}]
        table [y index = 1,skip first n={\n}] {\datafile};
}
\end{axis}
\end{tikzpicture}

It's not exactly a pleasing solution, but it does seem to be working somewhat:

Overlapping fixed somewhat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.