Unable to display Vincent sample maps; no suggested solutions work

限于喜欢 提交于 2019-12-05 04:35:58

问题


This is the same question as each of these questions, but none of the suggested solutions are working for me.

I'm trying to make a US State map in Python with the Vincent package, as shown in this tutorial. I'm using the Canopy editor. When I run this code, nothing shows up in my console. There are no errors that appear.

  • I've placed us_states.topo.json in my Python working directory.
  • I updated Canopy and Vincent.
  • I'm using vincent.core.initialize_notebook() as well as vis.display() like some other users have suggested.

I have no idea what I'm doing wrong....

import vincent

vincent.core.initialize_notebook()

state_topo = 'us_states.topo.json'

geo_data = [{'name': 'states',
             'url': state_topo,
             'feature': 'us_states.geo'},
             ]

vis = vincent.Map(geo_data=geo_data, scale=1000, projection='albersUsa')
vis.to_json('vega.json')
vis.display()

回答1:


If I'm correct Canopy editor can't render Vincent output.

You should use Vincent on the IPython/Jupyter notebook or just output the json to display it on a browser. The code on your example with some minor modifications is:

import vincent

vincent.core.initialize_notebook()
state_topo = "https://raw.githubusercontent.com/wrobstory/vincent_map_data/master/us_states.topo.json"
geo_data = [{'name': 'states',
             'url': state_topo,
             'feature': 'us_states.geo'}]

vis = vincent.Map(geo_data = geo_data, scale = 500, projection = 'albersUsa')
vis.to_json('vega.json')
vis.display()

And the output in an IPython/Jupyter notebook can be seen in the image below:

BTW, it seems Vincent is not updated and it wouldn't be. So, have a look for alternatives (e.g., Bokeh) if you don't want to use obsolete software.



来源:https://stackoverflow.com/questions/32377569/unable-to-display-vincent-sample-maps-no-suggested-solutions-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!