I'd like to make a bar chart with two basic conditions:
- Each bar has a name (not a numeric value)
- Each bar has its own color
I tried the following, but the result is terribly off. What am I missing?
\documentclass[a4paper, 12pt]{article}
\usepackage[paperwidth=5in, paperheight=3.2in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\geometry{left=0mm, right=3mm,top=6mm, bottom=3mm,}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=0,
symbolic y coords = {cat1, cat2, cat3}]
\addplot [fill=red] coordinates {(1,cat1)};
\addplot [fill=green] coordinates {(2,cat2)};
\addplot [fill=blue] coordinates {(3,cat3)};
\end{axis}
\end{tikzpicture}
\end{document}

bar shift=0ptand to avoid the "repeating" axis labels addytick distance=1to theaxisoptions. – Stefan Pinnow Jan 30 '21 at 08:43\addplotcommand per color, as you already did in your example.) – Stefan Pinnow Jan 30 '21 at 08:45