I needed this for a plot at work yesterday.
Not sure if we want to roll this into an explicit type (and I'm time constrained ATM regardless), but we could at least add it to the tips and tricks vignette. (Caveat: I don't think the RHS margin bump will work with themes.)
library(tinyplot)
palette("classic")
aq = airquality
aq$Month = factor(month.name[aq$Month], levels = month.name[5:9])
# for labels: subset to final dates for each month
aq2 = aq[aq$Day == ave(aq$Day, aq$Month, FUN = max), ]
plt(
Temp ~ Day | Month, data = aq,
type = "l", legend = FALSE, axes = 'l', grid = TRUE
)
text(
Temp ~ Day, data = aq2, labels = Month,
pos = 4, offset = 0.2,
xpd = NA, col = as.integer(Month)
)

The above is okay for shorter labels, but cuts off longer labels. We can bump the RHS margin to fix:
# bump rhs margin for longer labels
omar = par('mar')
omar[4] = omar[4] + max(strwidth(as.character(aq2$Month)))/2
op = par(mar = omar)
plt(
Temp ~ Day | Month, data = aq,
type = "l", legend = FALSE, axes = 'l', grid = TRUE
)
text(
Temp ~ Day, data = aq2, labels = Month,
pos = 4, offset = 0.2,
xpd = NA, col = as.integer(Month)
)

Created on 2025-06-17 with reprex v2.1.1
I needed this for a plot at work yesterday.
Not sure if we want to roll this into an explicit
type(and I'm time constrained ATM regardless), but we could at least add it to thetips and tricksvignette. (Caveat: I don't think the RHS margin bump will work with themes.)The above is okay for shorter labels, but cuts off longer labels. We can bump the RHS margin to fix:
par(op)Created on 2025-06-17 with reprex v2.1.1