2017-01-16 47 views
0

我正在用日期時間X軸繪製散景圖。當給劇情添加註釋時,我注意到時間是一個小時。我懷疑這是由於我在UTC + 1時區,儘管它也可能在某處存在某種+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) 

輸出: BokehData.png BokehPlot.png

我怎樣才能在正確的時間顯示的註釋?

編輯:它肯定與時區有關,因爲當我將系統時區更改爲UTC + 2時,偏移量爲2小時。

回答

0

這是這個問題https://github.com/bokeh/bokeh/issues/5499

背景虛化將把您的datetime對象作爲系統本地時間。您可以使用代碼開頭的那些行防止它使UTC + 0中的系統時間:

import os 
import time  

os.environ['TZ'] = 'UTC+0' 
time.tzset()