
Add RIVM-style tick marks between bar/column groups
Source:R/ro_gg_group_ticks.R
ro_gg_group_ticks.Rd
Replaces the default per-category axis ticks of a bar/column chart with tick marks placed
between each group of bars, following RIVM design guidelines. ggplot2 centers axis ticks under/next to each
category by default;
ro_gg_group_ticks() hides those and draws short line segments at the
boundary between every pair of adjacent categories instead, plus the two outer edges.
Since the tick marks are drawn just outside the panel area, always use this function in
combination with coord_cartesian(clip = "off").
Arguments
- plot
A ggplot object with a discrete category axis (e.g. from
geom_col()/geom_bar()).- flip
Logical. Set to
TRUEif the category axis isyrather thanx(the same orientation you'd pass totheme_ggrivm(flip = TRUE)). Default = FALSE.
See also
Other ggplot2:
ro_gg_axis(),
ro_gg_plot(),
ro_gg_remove_axis_gap(),
ro_gg_save(),
ro_gg_theme(),
ro_gg_y_title()
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
dat <- data.frame(agegroup = c("0-19", "20-39", "40-59"), n = c(1200, 4800, 6100))
p <- ggplot(dat, aes(agegroup, n)) +
geom_col() +
theme_ggrivm()
ro_gg_group_ticks(p) +
coord_cartesian(clip = "off")
} # }