【发布时间】:2017-01-16 11:10:07
【问题描述】:
我正在绘制带有日期时间 X 轴的散景图。在绘图中添加注释时,我注意到时间是一小时。我怀疑这是因为我处于 UTC+1 时区,尽管它也可能在某个地方存在一些 +1 索引差异。
要重现的代码:
xrange = pandas.date_range('1/1/2011', periods=12, freq='H')
event = pandas.Timestamp('1/1/2011 05:00:00')
data = pandas.Series([1]*12, index=xrange)
data[event] = 3
plot = bokeh.plotting.figure(x_axis_type="datetime")
plot.line(data.index, data)
time = event.timestamp()*1000
spanannotation = bokeh.models.Span(location=time, dimension="height",line_color="red")
plot.renderers.append(spanannotation)
bokeh.plotting.show(plot)
如何让注释显示在正确的时间?
编辑:它肯定与时区有关,因为当我将系统时区更改为 UTC+2 时,偏移量为 2 小时。
【问题讨论】:
标签: python pandas plot timestamp bokeh