---
name: Bar Chart
category: diagrams
description: Grouped bar chart with categorical x-axis using pgfplots
packages:
  - pgfplots
preamble:
  - \pgfplotsset{compat=1.18}
---
\begin{tikzpicture}
\begin{axis}[
  title={Grouped Bar Chart},
  ybar,
  bar width=12pt,
  xlabel={Category},
  ylabel={Value},
  symbolic x coords={A, B, C, D},
  xtick=data,
  legend style={at={(0.5,-0.2)}, anchor=north, legend columns=2},
  nodes near coords,
  width=0.8\textwidth,
  height=6cm,
]
  \addplot coordinates {(A, 20) (B, 35) (C, 30) (D, 45)};
  \addlegendentry{Series 1}

  \addplot coordinates {(A, 25) (B, 40) (C, 22) (D, 38)};
  \addlegendentry{Series 2}
\end{axis}
\end{tikzpicture}
