'Figure' 对象没有属性 'vbar'
'Figure' object has no attribute 'vbar'
这是我的代码,在 python 2.7 中,应该使用散景显示条形图:
from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource
from bokeh.palettes import Spectral6
from bokeh.plotting import figure
output_file("Option Bundling.html")
options= ['Option 1', 'Option 2', 'Option 1+2']
counts = [df3.get_value(select.value, select.value), df3.get_value(select2.value, select2.value), df3.get_value(select.value,select2.value) ]
source = ColumnDataSource(data=dict(options=options, counts=counts, color=Spectral6))
p = figure(x_range=options_list, y_range=(0,1), plot_height=250, title="Option Bundling",
toolbar_location=None, tools="")
p.vbar(x='options', top='counts', width=0.9, color='color', legend="Options", source=source)
p.xgrid.grid_line_color = None
p.legend.orientation = "horizontal"
p.legend.location = "top_center"
show(p)
当我在 Jupyter 中尝试 运行ning 时,出现以下消息:
AttributeError Traceback (most recent call last)
<ipython-input-29-a4eb97059982> in <module>()
14 toolbar_location=None, tools="")
15
---> 16 p.vbar(x='options', top='counts', width=0.9, color='color', legend="Options", source=source)
17
18 p.xgrid.grid_line_color = None
AttributeError: 'Figure' object has no attribute 'vbar'
代码来自bokeh文档,我只改了变量。我可以更改什么以使其成为 运行?
vbar
是最近添加的。最有可能的解释是您安装的 Bokeh 版本太旧,您需要升级才能使用 vbar
。如果您由于某种原因无法升级,quad
和 rect
将可用。
这是我的代码,在 python 2.7 中,应该使用散景显示条形图:
from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource
from bokeh.palettes import Spectral6
from bokeh.plotting import figure
output_file("Option Bundling.html")
options= ['Option 1', 'Option 2', 'Option 1+2']
counts = [df3.get_value(select.value, select.value), df3.get_value(select2.value, select2.value), df3.get_value(select.value,select2.value) ]
source = ColumnDataSource(data=dict(options=options, counts=counts, color=Spectral6))
p = figure(x_range=options_list, y_range=(0,1), plot_height=250, title="Option Bundling",
toolbar_location=None, tools="")
p.vbar(x='options', top='counts', width=0.9, color='color', legend="Options", source=source)
p.xgrid.grid_line_color = None
p.legend.orientation = "horizontal"
p.legend.location = "top_center"
show(p)
当我在 Jupyter 中尝试 运行ning 时,出现以下消息:
AttributeError Traceback (most recent call last)
<ipython-input-29-a4eb97059982> in <module>()
14 toolbar_location=None, tools="")
15
---> 16 p.vbar(x='options', top='counts', width=0.9, color='color', legend="Options", source=source)
17
18 p.xgrid.grid_line_color = None
AttributeError: 'Figure' object has no attribute 'vbar'
代码来自bokeh文档,我只改了变量。我可以更改什么以使其成为 运行?
vbar
是最近添加的。最有可能的解释是您安装的 Bokeh 版本太旧,您需要升级才能使用 vbar
。如果您由于某种原因无法升级,quad
和 rect
将可用。