In base R, I like to make plots with time on the x-axis where the labels are shown in between long tick marks. For example, there may be tick marks at June 1 and June 31, but the text "June" shows up in between, centered around June 15. In base R, I simply draw 2 axes, one with the ticks and one with the labels.
However, I haven't been able to figure out how to make this style of axis in ggplot2.
- Simply offsetting the text adjustment is not precise enough.
- Creating a single axis with
labels = c("","June","")
almost works but tick marks only accept one length so something likeaxis.ticks.length = unit(c(.25,0,.25),"cm")
doesn't work.
I think something like this might be possible with the ggh4x
package but I haven't been able to figure it out. I will be happy for any solution compatible with ggplot2, regardless of which package.