geom.bar() draws a rectangle per observation. In the default cartesian plane it produces vertical columns; add coord.flip() to lay them on their side as horizontal bars. One geom, two orientations. Columns suit comparing categories or a value over discrete time periods; bars suit ranking and categories with long labels that wouldn’t fit under a vertical axis.
Basic example
Value ony, category on x — the default cartesian form draws vertical columns:
Stacked and grouped
Map a category tocolor, then choose how the bars in each band arrange with position. In long format, one row per quarter × region:
'stack'— segments stacked into one column'dodge'— segments side by side within the band'fill'— stacked and normalised to 100%
Horizontal bars
Keep the natural mapping — category onx, value on y — and add coord.flip() to swap the axes. Stacking, grouping and styling all carry over unchanged; only the orientation differs:
Ranking
To order bars by value, sort the data with a transform — most useful with horizontal bars:Styling the bars
geom.bar() accepts params to style the rectangle:
Bar width as a fraction of the band, in
(0, 1].Corner rounding in pixels, or
'full' for pill-shaped bars.Border color. The border is only drawn when this is set.
Border width in pixels; only applies when
borderColor is set.Related
- Coordinate systems — how
coord.flip()works - Geoms & layers — position modes and layering
- Scales — control the value axis range

