我正在尝试为我的情节获得一个合适的日期时间可视化。它只显示日期时间轴的数值。当我将鼠标悬停在绘图上时,不会显示正确的日期时间
对我的代码有什么建议吗?时间戳采用2016-01-01 00:45:00
格式
# define source for ColumnDataSource
source = ColumnDataSource(df)
# define figure
plot = figure(plot_height=300, x_axis_type="datetime", sizing_mode="scale_width")
# add a glyph
plot.line('Datetime', 'Preis', source = source, legend='Ausgleichsenergiepreis')
# define hoverTool
hover_tool = HoverTool(tooltips=[('Time', '$Datetime'),('Price', '@Preis')], mode='vline')
hover_tool.formatters = {"Datetime": "datetime"}
plot.add_tools(hover)
# show plot
output_file('Ausgleichenergiepreise.html')
show(plot)
您可以将所需的日期时间格式附加到工具提示(请参见此处:
https://docs.bokeh.org/en/latest/docs/reference/models/tools.html
在关于HoverTool的工具提示部分)。这只是对代码的一个小小的补充:
相关问题 更多 >
编程相关推荐