Plot Bokeh教程在iPython Notebook 3/Jupyter上失败

Plot Bokeh教程在iPython Notebook 3/Jupyter上失败,plot,ipython-notebook,nameerror,bokeh,jupyter,Plot,Ipython Notebook,Nameerror,Bokeh,Jupyter,我仍在学习iPython笔记本/Jupyter以及如何与Bokeh一起绘图。我正在使用以下模型步骤: 但是我的代码在[13]中失败了:在他们的例子中。博克说: In [13]: from bokeh.models import Circle, HoverTool from bokeh.palettes import Spectral6 renderer_source = ColumnDataSource(bubble_plot.get_1964_data()) def add_circle

我仍在学习iPython笔记本/Jupyter以及如何与Bokeh一起绘图。我正在使用以下模型步骤: 但是我的代码在[13]中失败了:在他们的例子中。博克说:

In [13]:

from bokeh.models import Circle, HoverTool
from bokeh.palettes import Spectral6

renderer_source = ColumnDataSource(bubble_plot.get_1964_data())

def add_circles(plot):
    plot = add_text(plot)
    # Add the circle
    circle_glyph = Circle(
        x='fertility', y='life', size='population',
        fill_color='region_color', fill_alpha=0.8,
        line_color='#7c7e71', line_width=0.5, line_alpha=0.5)
    circle_renderer = plot.add_glyph(renderer_source, circle_glyph)

    # Add the hover (only against the circle and not other plot elements)
    tooltips = "@index"
    plot.add_tools(HoverTool(tooltips=tooltips, renderers=[circle_renderer]))
    return plot

show(add_circles(get_plot()))
我的代码在开始的第二步失败。以下是我使用自己的数据时的情况:

In [96]:

from bokeh.models import Circle, HoverTool

from bokeh.palettes import Spectral6

from bokeh.plotting import *

In [97]:

renderer_source = ColumnDataSource(bubble_plot.get_df())

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-97-8659183dfef3> in <module>()
----> 1 renderer_source = ColumnDataSource(bubble_plot.get_df())

NameError: name 'bubble_plot' is not defined
[96]中的

从bokeh.models导入圆,鼠标悬停工具
从bokeh.palets导入光谱6
从bokeh.plotting导入*
在[97]中:
renderer\u source=ColumnDataSource(bubble\u plot.get\u df())
---------------------------------------------------------------------------
NameError回溯(最近一次呼叫上次)
在()
---->1渲染器\u源=ColumnDataSource(bubble\u plot.get\u df())
名称错误:未定义名称“气泡图”

为什么
bubble\u plot
未定义,如何更改?这和他们的例子一模一样。到目前为止没有问题。谢谢大家!

泡泡图是在一个单独的python模块中定义的。您可以在笔记本顶部看到,它确实导入了气泡图来加载另一个模块。您可以在此处看到内容:


我知道结果,我试图将其用于我自己的数据,但没有成功。谢谢。对不起,我不明白你的回答。我没有重申结果。你问“为什么bubble\u plot未定义,我如何更改它?”我回答说你需要分别获取
bubble\u plot.py
模块,甚至给了你一个链接。