plot_bars: Bar chart coloured by value

View source: R/plot.R

plot_barsR Documentation

Bar chart coloured by value

Description

Bar chart coloured by value

Usage

plot_bars(
  data,
  x,
  y,
  horizontal = FALSE,
  sort = FALSE,
  cmap = "RdBu",
  title = NULL
)

Arguments

data

Data frame with the two columns

x

Category column (for example state_name or year)

y

Value column

horizontal

Draw horizontal bars (for long category names)

sort

Sort the bars by value, largest first

cmap

Diverging palette name from ggplot2::scale_fill_distiller(). The scale is centred on zero when there are negative values.

title

Plot title

Value

ggplot object

Examples


df <- data.frame(year = 2001:2010, dev = seq(-1, 1, length.out = 10))
plot_bars(df, "year", "dev")


varunayan documentation built on Oct. 30, 2026, 1:07 a.m.