Learning Python Data Visualization by Chad Adams

Learning Python Data Visualization by Chad Adams

Author:Chad Adams [Adams, Chad]
Language: eng
Format: epub, pdf
Publisher: Packt Publishing
Published: 2014-08-25T00:00:00+00:00


Now, let's look at our new pyramid chart in the next screenshot. We can see quite a bit of data. Each horizontal line shows you the number of miles traveled per mission, and as more of the launch time progresses, we can see the miles taper off for some of the earlier forms of space travel with satellites and shuttles using more miles.

Open the pyramid_chart.svg file, and the result will be as shown in the following screenshot:

Worldmap charts

I don't think the worldmap charts need much introduction. It's a worldmap that is separated into countries, which outputs to an SVG file. The worldmap chart is a fantastic feature of the pygal library and is partially why I like this Python charting library. This is because not many Python charting libraries have maps as a feature, let alone ones that use the SVG output, making the map charts pygal produce very portable chart files, in our modern HTML5 mobile world we live in today.

A simple worldmap is easy to build with a little bit of dummy data using the pygal library. Let's build a simple worldmap with only United States and China highlighted as an example. Copy the following code into your editor of choice, run your Python script, and let's take a look at the results. Also, ensure that you save your output SVG file as world_map.svg.

# -*- coding: utf-8 -*- import pygal worldmap_chart = pygal.Worldmap() worldmap_chart.title = 'Highlighting China and the United States' worldmap_chart.add('China', ['cn']) worldmap_chart.add('United States', ['us']) #Render file. worldmap_chart.render_to_file('world_map.svg')



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.