散景图不显示

编程入门 行业动态 更新时间:2024-10-23 04:56:20
本文介绍了散景图不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I am new to python. I tried the example given in here docs.bokeh/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):

更多推荐

散景图不显示

本文发布于:2023-07-18 12:53:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144978.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:散景图不

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!