I want to use geom_boxplot
and rescale my axis with scale_x_datetime
at the same time. However geom_boxplot
requires a factor
This seems to work as I expected. (You never did say how you expected.)
plot2 = plot1 + scale_x_discrete(labels=format.Date(x, "%Y/%m/%d %H"))
plot2
The point here is that you created an x-factor variable by using: aes(x=factor(a), y=b)
so any label formatting needs to respect the mode of the x-variable. I don't use ggplot2 because its widespread non-standard evaluation and code hiding drives me nuts, but I do think in terms of the basic modes and classes of R objects.