Python:hovertool和DatetimeAxis

2024-09-27 02:20:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试为我的情节获得一个合适的日期时间可视化。它只显示日期时间轴的数值。当我将鼠标悬停在绘图上时,不会显示正确的日期时间

You can see it hereenter image description here

对我的代码有什么建议吗?时间戳采用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)

Tags: addsourcedatetimeplotmodeshow时间tool

热门问题