Open
Description
The ggplot aesthetic specification doc gives a handy example of customizing linetypes, using the following format:
library(ggplot2)
lty <- c("11", "18", "1f", "81", "88", "8f", "f1", "f8", "ff")
linetypes <- data.frame(
y = seq_along(lty),
lty = lty
)
ggplot(linetypes, aes(0, y)) +
geom_segment(aes(xend = 5, yend = y, linetype = lty)) +
scale_linetype_identity() +
geom_text(aes(label = lty), hjust = 0, nudge_y = 0.2) +
scale_x_continuous(NULL, breaks = NULL) +
scale_y_reverse(NULL, breaks = NULL)

It could be handy to allow for something similar.
Background on ggplot2 syntax
ggplot2's linetype support matches base R's linetype specification (h/t tidyverse folks for the pointer):

This syntax allows each character in a string to specify width of "on" and "off" line parts. For example,
- "12" : 1 on, 2 off, repeat...
- "1234" : 1 on, 2 off, 3 on, 4 off, repeat...
It uses hexadecimal format, so allows for..
- "1f" : 1 on, 15 off
Proposed syntax
It seems like the R syntax could be supported directly. But I wonder if using an explicit separator might help clean things up a bit?
Something like:
- "1-2" : 1 on, 2 off
- "1-2-3-4": 1 on, 2 off, 3 on, 4 off
- "1-15": 1 on, 15 off
This way, it's clear what separates each piece, and people are constrained to a single character per part.