grantmcdermott · GitHub

Compare:

tinyplot

(Title position stays fixed)

factor2 = function(x) factor(x, levels = unique(x), labels = )
dat = data.frame(
  x = 1:12,
  mnth1 = factor2(1:12),
  mnth2 = factor2(month.name)
)
library(tinyplot)
tinytheme("clean")
plt(mnth1 ~ x, data = dat, type = "p",
    main = "Months of the year", sub = "A relevant subtitle")

plt(mnth2 ~ x, data = dat, type = "p",
    main = "Months of the year", sub = "A relevant subtitle")

tinytheme()

ggplot2

(Title shifts rightwards with longer y-axis labels. I think this looks better...)

library(ggplot2)
set_theme(theme_linedraw())
ggplot(dat, aes(x, mnth1)) + geom_point() +
  labs(title = "Months of the year", subtitle = "A relevant subtitle")

ggplot(dat, aes(x, mnth2)) + geom_point() +
  labs(title = "Months of the year", subtitle = "A relevant subtitle")

Created on 2025-09-16 with reprex v2.1.1

Read the original on github.com ↗