# Vertical bar chart with different colors for each bar [duplicate]

I'd like to create vertical bar chart with different color for each bar (each bar represents different landuse)

my current output is

I have alerady tried adding each bar as a different plot, but then it streches immensly and my lables dissapear. Anybody has an idea?

My curernt code

\documentclass[a4paper,onecolumn,oneside,12pt]
...
\usepackage{xcolor}
\usepackage{tikz}
....

\definecolor{hous}{HTML}{b88b4d}
\definecolor{green}{HTML}{79c561}
\definecolor{farming}{HTML}{ded94c}
\definecolor{trans}{HTML}{b4b4a9}
\definecolor{services}{HTML}{ff362e}
\definecolor{other}{HTML}{dbd4d3}
\definecolor{industry}{HTML}{db79c0}
\definecolor{water}{HTML}{7982db}
\definecolor{techinfra}{HTML}{303355}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=.5cm,
width=\textwidth,
height=.6\textwidth,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={Share of land use in \%},
symbolic x coords={Housing,Urban green,Farmlands,Transport infrastructure,Services,Other,Industrial,Water bodies,Technical infrastructure},
x tick label style={rotate=45, anchor=east, align=right,text width=3.5cm},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(Housing,28) (Urban green,28) (Farmlands,12) (Transport infrastructure,10) (Services,7) (Other,6) (Industrial,5) (Water bodies,3) (Technical infrastructure,1)};

\end{axis}
\end{tikzpicture}

\end{figure}
\end{document}


EDIT

I was able to find a solution, however it did not come from the suggested posts and was not a duplicate. Here's my solution:

    \begin{center}
\begin{figure} [H]
\label{landuse}
\begin{tikzpicture}
\begin{axis}[
ybar=-1cm,
axis x line*=bottom,
axis y line*=left,
height=8cm, width=\textwidth,
bar width=1cm,
ylabel={Share of land use in [\%]},
symbolic x coords={Housing,Urban green,Farmlands,Transport infrastructure,Services,Other,Industrial,Water bodies,Technical infrastructure},
x tick label style={rotate=45, anchor=east, align=left},
nodes near coords,
nodes near coords align={vertical}
]
\addplot[green,fill] coordinates {(Urban green,28)};
\addplot[trans,fill] coordinates {(Transport infrastructure,10)};
\addplot[water,fill] coordinates {(Water bodies,3)};
\addplot[techinfra,fill] coordinates {(Technical infrastructure,1)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{center}


and my current output.

hopefully it will help somebody

• Welcome to TeX.SX! Your question title is about vertical, your question about horizontal bars. Which type do you want? – TeXnician Jul 18 '17 at 18:10
• – Dr. Manuel Kuehner Jul 18 '17 at 18:11
• Sadly the suggestes answers are about horizontal bars and I really need a vertical one. And I tried to apply some of the solutions suggested there, sadly with the result I posted above. – MrsWicht Jul 18 '17 at 18:27
• Oh yes, it is a duplicate. The main idea which gives the desired result is to use bar shift=0pt (instead of ybar=-1cm) and to move each coordinate to a separate \addplot command. – Stefan Pinnow Jul 21 '17 at 5:06