散景图不显示

Bokeh figure doesn't show

我是 python 的新手。我用我自己的数据集尝试了此处 http://docs.bokeh.org/en/latest/docs/gallery/color_scatter.html 中给出的示例,它看起来像这样

   Unnamed: 0  fans                      id  stars
0           0    69  18kPq7GPye-YQ3LyKyAZPw   4.14
1           1  1345  rpOyqD_893cqmDAtJLbdog   3.67
2           2   105  4U9kSBLuBDU391x6bxU-YA   3.68
3           3     2  fHtTaujcyKvXglE33Z5yIw   4.64
4           4     5  SIBCL7HBkrP4llolm4SC2A   3.80

这是我的代码:

import pandas as pd

from bokeh.plotting import figure, show, output_file
op = pd.read_csv('FansStars.csv')

x = op.stars
y = op.fans
radii = 1.5
colors = ["#%02x%02x%02x" % (int(r), int(g), 150) for r, g in zip(50+2*x, 30+2*y)]

TOOLS="hover,crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,undo,redo,reset,tap,save,box_select,poly_select,lasso_select,"

p = figure(tools=TOOLS)

p.scatter(x, y, radius=radii,
      fill_color=colors, fill_alpha=0.6,
      line_color=None)

output_file("color_scatter.html", title="color_scatter.py example")

show(p)

但是,当我 运行 这段代码时,我没有收到任何错误,并且打开了一个网页,但是空白。重装了几次,终于可以看到工具了,仅此而已。 谁能告诉我哪里出错了? 谢谢!

我无法在 Python 3.4 和 Bokeh 0.12.3 上复制它。因此,这样一来,您的代码似乎还不错。我在笔记本 (output_notebook) 和像你一样的文件中都试过了,两者似乎都工作正常。

你指定的半径1.5是以数据为单位的(显然是x),这使得圆非常大,在第一次渲染时覆盖了整个屏幕。但是使用 wheelzoom 缩小一点可以按预期显示所有圆圈。以下是您的代码在 Firefox 中的样子(缩小后):