散景图不显示 [英] Bokeh figure doesn't show

查看:80
本文介绍了散景图不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am new to python. I tried the example given in here http://docs.bokeh.org/en/latest/docs/gallery/color_scatter.html with my own dataset, which looks like this

   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)

但是,当我运行此代码时,没有任何错误,并且打开了一个网页,但显示为空白.多次重载后,我终于可以看到这些工具了,仅此而已. 谁能告诉我我要去哪里错了? 谢谢!

However, when I run this code, I get no error and a webpage is opened, but BLANK. On reloading several times, I can finally see the tools, but that's all. Can anyone tell me where am I going wrong? Thanks!

推荐答案

我无法在Bokeh 0.12.3的Python 3.4上复制它.这样,您的代码就可以了.我在笔记本(output_notebook)和类似的文件中都尝试过,而且似乎都可以正常工作.

I cant replicate this on Python 3.4 with Bokeh 0.12.3. So in that way, your code seems fine. I tried it both in the notebook (output_notebook) and to a file like you do and both seem to work fine.

您指定的半径1.5以数据单位(显然是x)获取,这使圆变得非常大,第一次渲染时就覆盖了整个屏幕.但是,使用wheelzoom进行缩小会显示所有圆圈,这与预期的一样.对我来说,这是您的代码在Firefox中的样子(缩小后):

The radius of 1.5 which you specify is taken in data units (x apparently), this makes the circles extremely big, covering the entire screen at first render. But using the wheelzoom to zoom out a bit reveals all circles as expected. Here is what your code looks like in Firefox for me (after zooming out):

这篇关于散景图不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆