Titles

library(gglite)
p = g2(mtcars, hp ~ mpg)

1 Title and Subtitle via g2() Arguments

g2(mtcars, hp ~ mpg,
  title = 'Motor Trend Cars', subtitle = 'mpg vs horsepower')

2 Simple Title

p |> titles('Motor Trend Cars')

3 Title with Subtitle

p |> titles('Motor Trend Cars', subtitle = 'mpg vs horsepower')

4 Title Alignment

p |> titles('Right-aligned Title', align = 'right')

5 Title on a Bar Chart

df = data.frame(x = c('A', 'B', 'C', 'D'), y = c(3, 7, 2, 5))
g2(df, y ~ x) |>
  titles('Simple Bar Chart', subtitle = 'Categories A-D')