1

I am trying to use specific coloring in an table of ybar plots. Maybe someone can help me out here. I have read other threads concerning the coloration of ybars but none of them really worked.

This is what I have:

ybar plot

This is what I want:

differently colored ybar plot

That the "mean" symbol in the legend has 3 bars is especially tricky. The coloring is just something I can not accomplish.

Here is the code I used.

\documentclass[12pt,a4paper]{memoir}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}
% data1     
\pgfplotstableread{         
x            y      y-min   y-max
A   -9.647  0.524   0.468
B   -12.114 0.089   0.087
C   -14.902 0.483   0.435
}{\TabA}            
% data2         
\pgfplotstableread{         
x      y        y-min   y-max
A       -10.185 0.196   0.187
B   -12.656 0.283   0.265
C       -15.307 0.412   0.376
}{\TabB}                    
% mean          
\pgfplotstableread{         
x            y      y-min   y-max
A   -9.698  0.775   0.657
B   -13.608 2.495   1.575
C   -14.974 0.564   0.499
}{\TabSijMean}

\pgfplotsset{small}
\begin{center}
\begin{tabular}{lr}
\begin{tikzpicture}
\begin{axis}[width=8cm,
legend pos=north west, y dir=reverse,
enlarge x limits=0.2,
ybar=0,
xtick=data,
bar width=10pt,
symbolic x coords={A,B,C},
legend cell align=left
]

\addplot [ybar, fill=black!70] 
  plot [error bars/.cd, y dir=both, y explicit]
  table [y error plus=y-max, y error minus=y-min] {\TabA};
\addplot [ybar, fill=black!50] 
  plot [error bars/.cd, y dir=both, y explicit]
  table [y error plus=y-max, y error minus=y-min] {\TabB};  
\addplot [ybar, fill=blue] 
  plot [error bars/.cd, y dir=both, y explicit]
  table [y error plus=y-max, y error minus=y-min] {\TabSijMean};    
\legend{\tiny data1,\tiny data2,\tiny mean}
\end{axis}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{axis}[width=8cm,
ybar,
xtick=data,
symbolic x coords={A,B,C},
bar width=10pt,
enlarge x limits=0.2,
]
\addplot[fill=blue,error bars/.cd, y dir=both, y explicit] coordinates{(A,62.37) +-     (0,5.65)
(B,67.90) +- (0,5.527)
(C,64.04) +- (0,4.654)
};
\end{axis}
\end{tikzpicture}
\\
\end{tabular}%
\end{center}
\end{document}

I am really getting crazy here. Hopefully someone can help me.

Thanks BR

marked as duplicate by Stefan Pinnow, Fran, Zarko, Mensch, Mico Feb 28 '17 at 1:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.