# How to color groups of bars in a graph, coming form an external file?

I have a graph displaying bars and error bars, the numbers comming from an external .dat, being simply black and white.

And this is how I got there:

\documentclass[12pt]{report}
\usepackage{pgfplots}
\begin{figure} [ht]
\begin{tikzpicture}
\begin{axis}[xtick pos=left, unbounded coords=jump, scale=1.97, ybar, bar width=8pt, ylabel=$F_{Bruch}$\,${[N]}$,xtick=data,xticklabels from table={data.dat}{amount}]
table[x expr=\coordindex,y=FB,y error =sFB]{dataEB.dat};
\end{axis}
\end{tikzpicture}
\vspace{-25pt}
\small
\begin{tabbing}
xxxxxxxxxxxxx\=xxxx\kill
\>\begin{tabular}[htbp]{*{6}{@{}c}}
$\underbrace{\;\;\;\;\;\;\;\;\;\;\;\;\;\;}$ & \;\;\;\;\,$\underbrace{\;\;\;\;\;\;\;\;\;\;\;\;\;\;}$ & \;\;\,$\underbrace{\;\;\;\;\;\;\;\;\;\;\;\;\;\;}$ & \,$\underbrace{\;\;\;\;\;\;\;\;\;\;\;\;\;\;}$ & \,$\underbrace{\;\;\;\;\;\;\;\;\;\;\;\;\;\;}$ & \;$\underbrace{\;\;\;\;\;\;\;\;\;\;\;\;\;\;}$ \\
PEL80\,L & \;\;\;\;PEL80\,B & \,\;\;\;\;PEL90A\,L & \;\;\;PEL90A\,B & \;\;\,PEL90B\,L & \;\;PEL90B\,B \\
\end{tabular}
\end{tabbing}
\caption{bla bla}
\end{figure}


I had to tweak the original data, so the error bars are in correct position (had to insert a few nan to get my spacing).

And here is my question: How to get the bars of the different groups in different colors(e.g. PEL80L=red, PEL80B=green, ...)? And is there a smarter way to put those brackets below the groups?

data.dat (shortened in rows and columns):

Name        FB  sFM seM sFB seB amount
PEL80-L-0   196.971 7.1561  20.3208 6.9981  18.3839 0
PEL80-L-5   187.389 7.5195  15.8812 8.0784  15.2679 5
PEL80-L-10  202.529 5.0238  7.0358  3.6911  7.8109  10
PEL80-L-15  194.160 16.3605 40.9362 12.9954 41.6095 15
PEL80-B-0   192.586 2.1435  6.5643  3.1437  7.9701  0
PEL80-B-5   130.047 36.6504 19.4086 36.3431 19.6311 5
PEL80-B-10  77.6493 8.6906  1.6346  8.6906  1.6346  10
PEL80-B-15  79.3942 6.1144  0.9555  5.3075  1.2452  15


dataEB.dat:

Name        FB  sFM seM sFB seB amount
PEL80-L-0   196.9710 7.1561 20.3208 6.9981  18.3839 0
PEL80-L-5   187.3894 7.5195 15.8812 8.0784  15.2679 5
PEL80-L-10  202.5292 5.0238 7.0358  3.6911  7.8109  10
PEL80-L-15  194.1602 16.360 40.9362 12.9954 41.6095 15
nan     nan  nan    nan nan nan 0
PEL80-B-0   192.5864 2.1435 6.5643  3.1437  7.9701  5
PEL80-B-5   130.0471 36.650 19.4086 36.3431 19.6311 10
PEL80-B-10  77.6493  8.6906 1.6346  8.6906  1.6346  15
PEL80-B-15  79.3942  6.1144 0.9555  5.3075  1.2452  0
nan     nan  nan    nan nan nan 5

-
Hi Beli, welcome to the site! Do you want to colour the bars by series (so one colour for each \addplot command) or by group (so one colour for PEL80 L, one colour for PEL80 B, and so on)? It would be good if you could make the code snippet a complete compilable document by including the data (or dummy data). –  Jake Dec 11 '13 at 13:49
Can you provide a sample file of your data? Also, consider to make the width of your bars bigger, 10 and 15 are too close. »Bruch« is a textword, no variable, use \text{Bruch}. Units are typeset upright, use siunitx nicer units. Also, according to DIN 461 you must not give the units in square brackets [ ]. You also may want to have a look at texwelt.de/wissen/fragen/2283/… –  Johannes_B Dec 11 '13 at 13:50
The width of the bars was chosen this tight so the whole graph fits my textwidht (it's already too large about 11 pt) –  Beli Dec 11 '13 at 14:32
One suggestion: Put it in landscape. –  Johannes_B Dec 11 '13 at 14:37
There will be some text below the graph, so I would like to avoid rotating it. –  Beli Dec 11 '13 at 14:47