我想通过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是的我也得到了弃用警告。由于它超出了问题的范围,我没有考虑它。 :) –