combined use of geom_boxplot and scale_x_datetime

后端 未结 1 1698
情话喂你
情话喂你 2021-01-24 23:58

I want to use geom_boxplot and rescale my axis with scale_x_datetime at the same time. However geom_boxplot requires a factor

相关标签:
1条回答
  • 2021-01-25 00:18

    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.

    0 讨论(0)
提交回复
热议问题