2016-11-23 53 views
0

我是python新手。我想在这里http://bokeh.pydata.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) 

然而,当我运行此代码,我没有得到任何错误和网页被打开,但空白。在重新加载几次后,我终于可以看到这些工具,但仅此而已。 谁能告诉我我哪里错了? 谢谢!

+0

有没有在您的浏览器的JavaScript控制台的任何相关的输出或日​​志消息? – bigreddot

回答

0

我无法在Python 3.4上用Bokeh 0.12.3复制它。那样,你的代码就好了。我在笔记本(output_notebook)和像你这样的文件中都尝试过,两者似乎都很好。

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

enter image description here

+0

RAM可能是一个问题吗?它不会在我的系统上显示6GB RAM –

+0

带有4000个圆圈的'color_scatter.py'的整个输出大约是1Mb,因此除非您的数据集有数十亿行(这种情况下您需要查看类似的东西[背景虚化/ datashader](https://github.com/bokeh/datashader)) – bigreddot