我想通過Python中的散景獲得線條圖。我是Bokeh的新手,我試圖將懸停工具提示應用於情節。該圖的x軸具有時間戳值,它們被轉換爲時間戳字符串。我在這裏回顧了一些相同的問題,並試圖對我的案例使用解決方法,但似乎沒有工作。在陰謀它給出???
時間應該顯示。Python:散焦懸停日期時間
對我的代碼有任何建議嗎?
時間戳是格式2016-12-29 02:49:12
也可以有人告訴我如何格式化x-axis
蜱垂直顯示?
p = figure(width=1100,height=300,tools='resize,pan,wheel_zoom,box_zoom,reset,previewsave,hover',logo=None)
p.title.text = "Time Series for Price in Euros"
p.grid.grid_line_alpha = 0
p.xaxis.axis_label = "Day"
p.yaxis.axis_label = "Euros"
p.ygrid.band_fill_color = "olive"
p.ygrid.band_fill_alpha = 0.1
p.circle(df['DateTime'],df['EuP'], size=4, legend='close',
color='darkgrey', alpha=0.2)
p.xaxis.formatter = DatetimeTickFormatter(formats=dict(
hours=["%d %B %Y"],
days=["%d %B %Y"],
months=["%d %B %Y"],
years=["%d %B %Y"],
))
source = ColumnDataSource(data=dict(time=[x.strftime("%Y-%m-%d %H:%M:%S")for x in df['DateTime']]))
hover = p.select(dict(type=HoverTool))
hover.tooltips = {"time":'@time', "y":"$y"}
hover.mode = 'mouse'
p.line(df['DateTime'],df['EuP'],legend='Price',color='navy',alpha=0.7)
此代碼在python2.7我的0.12.3版本的背景虛化工作非常。但它有一個棄用警告:背景虛化/ UTIL/deprecation.py:33:BokehDeprecationWarning:DatetimeTickFormatter.formats被棄用散景0.12.3和將被刪除,使用單獨的DatetimeTickFormatter領域代替。 警告(消息) –
@PabloReyes是的我也得到了棄用警告。由於它超出了問題的範圍,我沒有考慮它。 :) –