error with scale_x_labels in ggplot2

前端 未结 1 821
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 04:19

I am trying to recreate the charts in this book using ggplot2. The data I am using is at the bottom of the post from a dput. It is available from the publisher\

相关标签:
1条回答
  • 2020-12-18 04:41

    You should use scale_x_datetime since you have POSIXct :

     scale_x_datetime(labels=date_format("%Y %H:%M"))
    

    Or convert you Date variable to a Date ( without time part)

    chartout$Date <- as.Date(chartout$Date) 
    

    And I would use this format :

    scale_x_date(labels = date_format("%m %b")) +
    

    enter image description here

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