无法在iPython笔记本中使用Vincent绘制世界地图(Unable to plot worldmap with Vincent in iPython notebook)

编程入门 行业动态 更新时间:2024-10-26 07:31:21
无法在iPython笔记本中使用Vincent绘制世界地图(Unable to plot worldmap with Vincent in iPython notebook)

这个问题可能与在IPython中使用vincent的Unable情节有关,尽管我认为这不是完全相同的问题。

我可以在IPython 0.13.1笔记本中使用Vincent 0.4.4绘制条形图,如下例所示(在文档中找到):

import vincent vincent.core.initialize_notebook() bar = vincent.Bar(multi_iter1['y1']) bar.axis_titles(x='Index', y='Value') bar.display()

但是,我无法对数据映射示例中的worldmap表示做同样的事情:

import vincent geo_data = [{'name': 'countries', 'url': world_topo, 'feature': 'world-countries'}] vis = vincent.Map(geo_data=geo_data, scale=200) vis.to_json('vega.json')

我已将值'world_topo'替换为从此处下载的Topojson文件(world-countries.topo.json)的路径。

没有显示错误,也没有任何反应。 顺便说一下,我没有使用HTTPS。 这是最简单的地图图示例,所以我想它应该可以顺利运行......

有任何想法吗?

This question is probably related to Unable plot with vincent in IPython , although I think it's not exactly the same problem.

I can plot a bar chart using Vincent 0.4.4 in an IPython 0.13.1 notebook as in the following example (found in the docs):

import vincent vincent.core.initialize_notebook() bar = vincent.Bar(multi_iter1['y1']) bar.axis_titles(x='Index', y='Value') bar.display()

However, I'm unable to do the same thing with the worldmap representation in the data mapping example:

import vincent geo_data = [{'name': 'countries', 'url': world_topo, 'feature': 'world-countries'}] vis = vincent.Map(geo_data=geo_data, scale=200) vis.to_json('vega.json')

I've replaced the value 'world_topo' with the path to the Topojson file (world-countries.topo.json) downloaded from here.

No errors are shown and nothing happens. I'm not using HTTPS, by the way. This is the simplest map chart example, so I guess it should work smoothly...

Any ideas?

最满意答案

在vincent的网页之后,需要一个> = 1.0的IPython版本,因此,升级到更新的版本(例如IPython 2.1)很可能解决您的问题。 在我的ubuntu机器上,vega的地图可以很好地工作。

此外,需要在设置绘图后调用vis.display()方法, 如此示例笔记本中所示 。

Following the webpage of vincent an IPython version of >= 1.0 is required, thus, an upgrade to a more recent version (e.g. IPython 2.1) is very likely to solve your problem. On my ubuntu machine the map plot of vega works nicely.

Moreover, it is required to call the vis.display() method after the setup of the plots, as shown in e.g. this example notebook.

更多推荐

本文发布于:2023-07-25 22:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1267163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:世界地图   笔记本   Vincent   iPython   notebook

发布评论

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

>www.elefans.com

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