ggplot python handling time data over many weeks at hourly resolution
I am plotting journey time for a series of roads at hourly resolution, with data over a few weeks.
I can plot using unix time, but that isn't very intuitive. This is 7 days worth of data.
I used a function to manipulate the time
field in order to give the date and hour:
def plot_time(time):
return time.strftime('%Y-%m-%d-%H')
However, this results in ggplot throwing a value error when trying to plot:
ValueError: invalid literal for float(): 2016-04-13-00
Is there a simpler means of displaying date and some hour?
Alternatively I could plot unix time with a date scale on the axis but it would be nice to have some hour resolution on the axis.
POSIXct
was the key here as bVa said.
ggplot(aes(x=as.POSIXct(epoch_time,origin="1970-01-01"),y=lambda)
Once the epoch time was formated POSIXct, it was possible to use scale_x_datetime()
I settled on:
+ scale_x_datetime(breaks=date_breaks("1 day"))
我认为scale_date是你确切需要的。
链接地址: http://www.djcxy.com/p/33724.html