Staying with continuous data, you can get the breaks at the correct location if they're in the right unit:
p1 +
scale_x_break(as.Date(c("2025-04-01", "2025-05-01")))
Unfortunately, this converts the labels to numeric. But, scales_x_break()
can be combined with other scales! So we can add a scale_x_continuous()
on top of it to force relabelling:
p1 +
scale_x_break(as.Date(c("2025-04-01", "2025-05-01"))) +
scale_x_continuous()
This is not enough: it just adds a second numeric scale in a weird way I can't explain. But, if we specify the breaks ourselves:
p1 +
scale_x_break(as.Date(c("2025-04-01", "2025-05-01"))) +
scale_x_continuous( breaks = scales::breaks_pretty(n = 10)(df$date) )
There is still a double scale on top, no idea why, but at least they all display correct dates.