Skip to contents

Simple bar chart

Usage

bar(
  df,
  x,
  y,
  group = NULL,
  flip = TRUE,
  percent = TRUE,
  wrap = NULL,
  position = "dodge",
  alpha = 1,
  x_title = NULL,
  y_title = NULL,
  group_title = NULL,
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  add_text = FALSE,
  add_text_suffix = "",
  theme = theme_reach()
)

Arguments

df

A data frame.

x

A numeric column.

y

A character column or coercible as a character column.

group

Some grouping categorical column, e.g. administrative areas or population groups.

flip

TRUE or FALSE. Default to TRUE or horizontal bar plot.

percent

TRUE or FALSE. Should the x-labels (and text labels if present) be displayed as percentages? Default to TRUE.

wrap

Should x-labels be wrapped? Number of characters.

position

Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack".

alpha

Fill transparency.

x_title

The x scale title. Default to NULL.

y_title

The y scale title. Default to NULL.

group_title

The group legend title. Default to NULL.

title

Plot title. Default to NULL.

subtitle

Plot subtitle. Default to NULL.

caption

Plot caption. Default to NULL.

add_text

TRUE or FALSE. Add the value as text.

add_text_suffix

If percent is FALSE, should we add a suffix to the text label?

theme

Whatever theme. Default to theme_reach().

Value

A bar chart