Основываясь на первом примере руководства пользователя Bokeh,
from bokeh.io import show, output_file
from bokeh.plotting import figure
from bokeh.models import Span
output_file("bars.html")
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
counts = [5, 3, 4, 2, 4, 6]
p = figure(x_range=fruits, plot_height=250, title="Fruit Counts",
toolbar_location=None, tools="")
p.vbar(x=fruits, top=counts, width=0.9)
# these two lines
vline = Span(location='Apples', dimension='height', line_color='blue', line_width=4)
p.renderers.extend([vline])
p.xgrid.grid_line_color = None
p.y_range.start = 0
show(p)
Я пытаюсь добавить вертикальную линию к гистограмме, чей диапазон х - это категории.Однако это не представляется возможным, так как при этом возникает ошибка «ValueError: ожидаемое значение типа Real, получены яблоки типа str».
location='Apples'
не работает так, как предполагалосьчисло.