R: as.POSIXct timezone and scale_x_datetime issues in my dataset

后端 未结 2 675
心在旅途
心在旅途 2020-12-18 21:51

I spent some time trying to figure out why the hour ticks were shifted when scale_x_datetime was applied. I\'ve tried to give the timezone when the Date/Time column was crea

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 22:45

    Update for ggplot 3+. scale_x_datetime allows you to set the x-axis time zone directly (using a syntax slightly different than that given in older answers). The correct code now is:

    scale_x_datetime(limits = lims, breaks = date_breaks("2 hour"),
                     date_labels = "%m/%d %H:%M",
                     timezone = "America/Toronto")
    

提交回复
热议问题