Greetings,
I have been trying to figure out how to insert a label or text in my timeseries plot. I keep getting an error.
Either.
-
ValueError: expected a value of type Real, got 2013-07-03 00:00:00 of type Timestamp (using Label())
-
ValueError: expected an element of either String, Dict(String, Either(String, Instance(Transform), Instance(ColorMapper), Float)) or Float, got Timestamp(‘2013-07-03 00:00:00’, offset=‘B’)
I am not sure what I am doing wrong. I would be grateful for any help. I tried using DatetimeIndex and PeriodIndex
An example below of the errors are below using Bokeh 0.12.4 and python 3.5.2:
import numpy as np
import pandas as pd
from bokeh.plotting import figure, output_file, show
from bokeh.models import Label
x = pd.date_range(‘2010-01-01’,‘2017-01-01’, freq= ‘B’)
y = x.to_period(‘B’)
data = np.random.randn(len(x))*100
output_file(‘label_test.html’)
timeseries = pd.Series(data, index = x)
timeseries2 =pd.Series(data, index = y)
plot1 = figure(x_axis_type = ‘datetime’)
plot1.line(x, data)
plot1.text(x = x[len(x)//2], y = np.max(data), text = ‘success’)
point1 = Label(x= x[len(x)//2], y = np.max(data), text= ‘Success’, render_mode = ‘canvas’)
plot1.add_layout(point1)
show(plot1)

