I've got a issue with the datetime format on my hovertool. I'm not sure but i think since i've updated bokeh and pandas to the latest version (bokeh: v2.0.1 / pandas v1.0.3) in conda the presentation of the dates in my bokeh plot are faulty.
import pandas as pd
# first of all i create a columndatasource and convert my datetime-strings to pandas datetime-objects:
Source = ColumnDataSource(data={'date' : pd.to_datetime(df_data['Date'], format='%Y-%m'),
'values' : df_data['values']})
#print(pd.to_datetime(df_data['Datum'], format='%Y-%m'))
# >>>
#0 1980-01-01
#1 1980-02-01
#2 1980-03-01
#...
hover = HoverTool(tooltips = [('Month', '@date{%b, %Y}'),('Value', '@values{0.0} °C')],
formatters = {'date' : 'datetime'}, mode='vline')
plot = figure(x_axis_label='time',
x_axis_type='datetime',
y_axis_label='diff',
tools = [hover, 'pan', 'box_zoom', 'wheel_zoom', 'reset'],
background_fill_color = '#2F4F4F',
output_backend="webgl",
toolbar_location='right',
title="Title")
plot.vbar(x = 'Month',top = 'Value', source=Source, width=timedelta(days=20), color='color')
But if i run this, it shows me for "Month" in my hovertool something like "80TiB %" and not "Apr 2020".
The key in the formatters
dictionary has to match the field specification exactly, including any prefix:
formatters = {'@date' : 'datetime'}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments