Skip to contents

Three-line pass-throughs that ship consulting-grade defaults for ggplot2::geom_col() width, ggplot2::geom_line() linewidth, and ggplot2::geom_point() size. Use them when you want the defaults baked into the call site; plain geom_line() will also pick up linewidth from ct_theme() / theme_strategy() via from_theme(), and geom_point() size is autoloaded by ct_set_defaults().

Usage

ct_col(..., width = 0.8)

ct_line(..., linewidth = 0.7)

ct_point(..., size = 2.5)

Arguments

...

Forwarded to the underlying ggplot2 constructor.

width

Column width. Defaults to 0.8 (vs ggplot2's 0.9).

linewidth

Line width. Defaults to 0.7 (vs ggplot2's 0.5).

size

Point size. Defaults to 2.5 (vs ggplot2's 1.5).

Value

A ggplot2 ggplot2::layer() object.

Bar charts with Date x

ct_col()'s default width = 0.8 is in x-axis units. On a Date x-axis that is 0.8 days, which renders bars as slivers when the data is spaced quarterly or monthly. For bar charts, convert the x variable to either an ordered factor (e.g. "21Q1", "21Q2", ...) or a numeric index before plotting; line charts on Date are fine.

Examples

library(ggplot2)
d <- data.frame(g = c("A", "B", "C"), v = c(3, 5, 2))
p_col   <- ggplot(d, aes(g, v)) + ct_col()
p_line  <- ggplot(economics, aes(date, unemploy)) + ct_line()
p_point <- ggplot(mtcars, aes(wt, mpg)) + ct_point()