I have the following bar chart and I would like to color each column differently. Both columns are in the same plot, when I separate them just to give a different color values for each one the appearance of the bar chart changes. Is there a way to specify different colors for the same plot?
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{bchart}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{subfig}
\pgfplotsset{compat=1.10}
\definecolor{RYB2}{RGB}{245,245,245}
\definecolor{RYB1}{RGB}{218,232,252}
\definecolor{RYB4}{RGB}{108,142,191}
\begin{document}
\begin{figure}
\centering
\subfloat[][name]{\resizebox{0.45\textwidth}{!}{
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={col1, col2, col3},
xtick=data,
ylabel=Passed Challenges(\%),
xticklabel style={rotate=45,anchor=north east},
ymajorgrids,
bar width=17pt,
]
\addplot[ybar,fill=RYB1] coordinates {
(col1, 44.71)
(col2, 26.57)
(col3, 45.42)
};
\end{axis}
\end{tikzpicture}}}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\end{document}
Thank you
Best Answer
Just do
\addplot
for each column with a defined color.