Community Data Science Workshops (Spring 2014)/Saturday May 31st Matplotlib Session: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Mako
No edit summary
imported>Jtmorgan
m (moved to wiki.communitydata.cc)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{CDSW Moved}}
[[File:Wikipedia.png|right|250px]]
[[File:Matplotlib-hist2d.png|right|500px]]
__NOTOC__
__NOTOC__
== Visualizing data with Matplotlib and Wiki-bios ==
== Visualizing data with Matplotlib and Wiki-bios ==
Line 5: Line 6:
In this project, we will explore how to produce clear, informative charts, graphs, and plots with [http://matplotlib.org/ Matplotlib], the most popular toolkit for scientific data visualization in Python.
In this project, we will explore how to produce clear, informative charts, graphs, and plots with [http://matplotlib.org/ Matplotlib], the most popular toolkit for scientific data visualization in Python.


We'll be focusing on a dataset drawn from Wikipedia and [http://dbpedia.org dbPedia], containing the names, birth dates, genders, article creation dates, and number of edits, of over 180,000 Wikipedia biography articles.
We'll be focusing on a dataset drawn from Wikipedia and [http://dbpedia.org DBpedia], containing the names, birth dates, genders, article creation dates, and number of edits, of over 180,000 Wikipedia biography articles.


=== Goals ===
=== Goals ===
Line 17: Line 18:
* Exercise your creativity by making your own visualization
* Exercise your creativity by making your own visualization


=== Prerequisites ===
=== Set up ===


If you installed Anaconda, you are good to go. All Windows users have already installed Anaconda.
In addition to Python and a text editor, you must also download and install the appropriate matplotlib version for your system, which is available [http://matplotlib.org/downloads.html here].

If you are running OSX, and have not yet [[Windows set up Python (Anaconda)#Download and install Python|installed Anaconda]], please do. You can follow these instructions for Windows users, but make sure you select the right version of Anaconda for your system.

On a Linux system, you'll need to install some dependencies (e.g. for Debian-based systems):

<pre>
sudo apt-get install python-matplotlib python-tk
</pre>


=== Download and test the Matplotlib-with-Wiki-bios project ===
=== Download and test the Matplotlib-with-Wiki-bios project ===
Line 27: Line 36:
After installing matplotlib, and downloading and unpacking the Wikibios bundle, move into that directory with '''cd'''. You can test your installation by running '''python histograms.py'''. If matplotlib is install correcting, a chart file named '''histograms.pdf''' will appear in the current directory.
After installing matplotlib, and downloading and unpacking the Wikibios bundle, move into that directory with '''cd'''. You can test your installation by running '''python histograms.py'''. If matplotlib is install correcting, a chart file named '''histograms.pdf''' will appear in the current directory.


[http://mako.cc/teaching/2014/cdsw/wikibios.zip Wikibios bundle for all platforms]
TODO(mako): Add download links here.


=== Example topics to cover in Lecture ===
=== Example topics to cover in Lecture ===

[[File:Matplotlib-hist2d.png|right|500px]]


* line charts
* line charts
Line 40: Line 47:
* axis labeling
* axis labeling
* legends
* legends

[[File:Wikipedia.png|right|250px]]

Latest revision as of 22:11, 15 March 2015

Page Moved
All material related to the Community Data Science Workshops have been moved from the OpenHatch wiki to a new dedicated wiki and this page is no longer being updated here. Please visit the new version of the page on the Community Data Science Collective wiki.

Visualizing data with Matplotlib and Wiki-bios

In this project, we will explore how to produce clear, informative charts, graphs, and plots with Matplotlib, the most popular toolkit for scientific data visualization in Python.

We'll be focusing on a dataset drawn from Wikipedia and DBpedia, containing the names, birth dates, genders, article creation dates, and number of edits, of over 180,000 Wikipedia biography articles.

Goals

  • Get set up to make graphs with Matplotlib
  • Learn the basics of the Matplotlib API and workflow
  • Practice reading the Matplotlib documentation
  • Build a plotting program step by step
  • Learn simple ways to distill the essence of a large data set
  • Explore the art of visualizing data
  • Exercise your creativity by making your own visualization

Set up

If you installed Anaconda, you are good to go. All Windows users have already installed Anaconda.

If you are running OSX, and have not yet installed Anaconda, please do. You can follow these instructions for Windows users, but make sure you select the right version of Anaconda for your system.

On a Linux system, you'll need to install some dependencies (e.g. for Debian-based systems):

sudo apt-get install python-matplotlib python-tk

Download and test the Matplotlib-with-Wiki-bios project

(Estimated time: 10 minutes)

After installing matplotlib, and downloading and unpacking the Wikibios bundle, move into that directory with cd. You can test your installation by running python histograms.py. If matplotlib is install correcting, a chart file named histograms.pdf will appear in the current directory.

Wikibios bundle for all platforms

Example topics to cover in Lecture

  • line charts
  • histograms
  • binning
  • scatter plots
  • heat maps
  • axis labeling
  • legends