Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Matplotlib Recipes for your graphical soups @ P...

Matplotlib Recipes for your graphical soups @ PyCon 5

The term **Data Visualization** (a.k.a. *data viz*) refers to any visual
representation of data that is *algorithmically drawn* [[Illinsky & Steele, 2011]][0].
In particular, *data viz* is easy to regenerate (with different data); it is often aesthetically barren;
and it is relatively data-rich, usually representing large volume of data [[Illinsky & Steele, 2011]][0].

Data viz approaches are further distinguished in two distinct categories, namely *static* and *interactive*
visualizations. Static visualizations can offer only precomposed *views* of data, so multiple static views
are often needed to present a variety of perspectives on the same information [[Murray, 2013]][1].
On the other hand, (dynamic) interactive visualization tools allow the users to customize the way they
want to *view* the plotted data.

[Matplotlib](http://matplotlib.org) is a very powerful data visualization library, being so far the *de-facto*
standard data viz library for **Python** code.

Matplotlib offers a wide variety of 2D and 3D plots, graphics and maps (`matplotlib.basemap`) typically useful
in case of (but not limited to) data analysis in scientific contexts.
All the generated plots may be further customized (e.g.,
*annotating charts with LateX formulas*, *changing fonts and colors* ) in order to make them perfectly
suited for the different requirements we may have.

Last but not least, recent versions of the library started supporting creation of animated graphics and charts
(i.e., `matplotlib.animations`)

Most of the charts provided out-of-the-box by the library belongs to the *static data viz* category.
However, the new **MLPD3** [project](http://mpld3.github.io) aims at integrating Matplotlib with the
[**D3js**](http://d3js.org), the popular Javascript library to generate data-driven web pages.

This talk is going to present the main features and capabilities provided by the
`matplotlib` library in a very **recipe-oriented** and practical fashion.
The main goal of the talk is to emphasize *when* and *how* the different Matplotlib charts could be effectively
used, depending on the considered problem to tackle.

To this end, several code recipes will be discussed during the presentation.
Recipes using `mpld3` and `matplotlib.animations` for the *interactive data viz* will be presented as well,
and will conclude the talk

This talk assumes a good knowledge of the Python language.
Basic knowledge of `numpy` and `scipy` is also a plus.

[0]: http://www.amazon.it/Designing-Data-Visualizations-Julie-Steele/dp/1449312284/ "Designing Data Visualization"
[1]: http://www.amazon.it/Interactive-Data-Visualization-Scott-Murray/dp/1449339735/ "Interactive Data Visualization for the Web"

Valerio Maggio

May 25, 2014
Tweet

More Decks by Valerio Maggio

Other Decks in Programming

Transcript

  1. Data Visualisation (a.k.a. data viz) refers to any visual representation

    of data that is algorithmically drawn [Illinsky & Steele, 2011].
  2. Data Visualisation is • easy to regenerate (with different data);

    • often aesthetically barren; • relatively data-rich • usually representing large volume of data
  3. • matplotlib is a python 2D plotting library which produces

    publication quality figures in a variety of hardcopy formats and interactive environments across platforms. matplotlib can be used in python scripts, the python and ipython shell (ala MATLAB® or Mathematica®†), web application servers, and six graphical user interface toolkits.
  4. • Very Pythonic • Nice API • Full featured •

    Very useful for scientific stuff • Integration with numpy and scipy • Anyway... Not for Science only!!
  5. what we missed • Histograms • special cases of BarCharts

    for Probability Distributions • Horizontal BarCharts (barh) • Pie Charts • Box Plots • Path Plots • Stream Plots • …. http://matplotlib.org/gallery.html