Exporting Images from Vincent in ipython

878 Views Asked by At

I've been using vincent in python to make choropleth maps, now i'd like to make them into images to use for a presentation. Does anyone know how to do this? Below is the code I'm using:

county_borders = r'us_counties.topo.json'
geo_data = [{'name': 'counties',
         'url': county_borders,
         'feature': 'us_counties.geo'}]
choro_pop = vincent.Map(data=counties_only, geo_data=geo_data, scale=1500, projection='albersUsa',
      data_bind='CENSUS2010POP', data_key='FIPS',
      map_key={'counties': 'properties.FIPS'})
choro_pop.marks[0].properties.enter.stroke_opacity = ValueRef(value=0.5)
choro_pop.rebind(column = 'ESTIMATESBASE2010', brew = 'OrRd')
choro_pop.to_json('Counties_Population_choropleth.json', html_out=True, html_path='Counties_Population_choropleth.html')
choro_pop.display()

This gives me a map in the ipython notebook (yay!) and outputs both an html file and a .json file. The html file is just a "scaffold" it doesn't actually contain any data that I can tell, and it doesn't display anything when opened in a browser (I've tried chrome).

The .json file I know is dictionary-like, but I'm not sure how to use it to draw a nice image.

thanks!

edit1: This is what's in the html file

<html>
  <head>
    <title>Vega Scaffold</title>
    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="http://d3js.org/topojson.v1.min.js"></script>
    <script src="http://d3js.org/d3.geo.projection.v0.min.js" charset="utf-8">    </script>
    <script src="http://trifacta.github.com/vega/vega.js"></script>
  </head>
  <body>
    <div id="vis"></div>
  </body>
<script type="text/javascript">
// parse a spec and create a visualization view
function parse(spec) {
  vg.parse.spec(spec, function(chart) { chart({el:"#vis"}).update(); });
}
parse("Counties_Population_change_choropleth.json");
</script>
</html>
0

There are 0 best solutions below