python - Exporting Images from Vincent in ipython -
i've been using vincent in python make choropleth maps, i'd make them images use presentation. know how this? below 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 map in ipython notebook (yay!) , outputs both html file , .json file. html file "scaffold" doesn't contain data can tell, , doesn't display when opened in browser (i've tried chrome).
the .json file know dictionary-like, i'm not sure how use draw nice image.
thanks!
edit1: what's in 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 spec , create visualization view function parse(spec) { vg.parse.spec(spec, function(chart) { chart({el:"#vis"}).update(); }); } parse("counties_population_change_choropleth.json"); </script> </html>
Comments
Post a Comment