2

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()
Community
  • 1
  • 1
ale19
  • 1,327
  • 7
  • 23
  • 38

1 Answers1

3

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:

enter image description here

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.

kikocorreoso
  • 3,999
  • 1
  • 17
  • 26
  • Thanks very much! Mystery solved. I was using Bokeh for a while, but their maps don't display Michigan-- which is a bit of a problem since I work in Michigan! I guess I'll just have to work around that, then. – ale19 Sep 03 '15 at 17:38