Python graphics libraries for data visualization

Pandas

The Python Data Analysis (Pandas) Library is available under a BSD-style license. The name is derived from "panel data" and suits multidimensional structured data. The developers have optimized Pandas for speed and therefore implemented critical sections of code in Cython and C. Cython is an optimizing static compiler for Python and the advanced programming language of the same name. It creates compiled C programs that run several times faster than the source code in the Python interpreter.

Listing 3

Pandas Plot

 

Figure 7 compares the frequency of selected children's names; see Listing 3 for the corresponding code. After defining the required modules (Lines 1 to 3), you set the data to be visualized. Lines 5 and 6 define two lists, one with the name and another with the respective frequency.

Figure 7: Frequency of children's names.

Using the internal Python functions list and zip, line 7 creates a two-dimensional dataset, from which Pandas generates a view in line 9. You need to assign the collected data to the data parameter, the data labels to columns, and the names defined in line 5 to index.

Pandas renders the frequency of the name along the y axis while outputting the name in the corresponding bar on the x axis as an identifier. The call in line 10 uses df.plot() and the parameter kind='bar' to produce the chart.

Conclusions

The Matplotlib, PyQtGraph, Bokeh, and Pandas libraries can help programmers convert abstract data to clear-cut representations with a reasonable amount of effort. Basic knowledge of Python considerably simplifies the use of these visualization libraries. If you are looking to create a specific look, you might need to experiment.

The featured libraries provide extensive capabilities and require a careful reading of the API to set the parameters correctly. Thus, you need patience and the motivation to work through the detailed documentation. The supplied examples will help you familiarize yourself with the order and effect of the calls.

Infos

  1. Matplotlib: http://matplotlib.org/
  2. PyQtGraph: http://www.pyqtgraph.org/
  3. Bokeh: http://bokeh.pydata.org/en/latest/
  4. Pandas: http://pandas.pydata.org/
  5. Perl module PLplot: http://plplot.sourceforge.net/index.php
  6. Perl module Chart::Clicker: https://metacpan.org/pod/Chart::Clicker
  7. Perl module GD::Graph: https://metacpan.org/pod/GD::Graph
  8. GD library (PHP): http://php.net/manual/en/book.image.php
  9. JpGraph (PHP): http://jpgraph.net/
  10. JavaScript InfoVis Toolkit: http://philogb.github.io/jit/
  11. D3: https://d3js.org/
  12. Crossfilter: http://square.github.io/crossfilter/
  13. jqPlot: http://www.jqplot.com/
  14. jQuery-Visualize: https://github.com/filamentgroup/jQuery-Visualize
  15. Flot: http://www.flotcharts.org/
  16. R: https://www.r-project.org/
  17. Data visualization tools: http://selection.datavisualization.ch/
  18. "The 38 best tools for data visualization" by By Brian Suda and Sam Hampton-Smith: http://www.creativebloq.com/design-tools/data-visualization-712402
  19. "What's new in Python 3" by Rainer Grimm, Linux Pro Magazine, issue 107, October 2009, pg. 42, http://www.linuxpromagazine.com/Issues/2009/107/Python-3
  20. Basemap: http://matplotlib.org/basemap/
  21. Cartopy: http://scitools.org.uk/cartopy/docs/latest/
  22. IPython Notebook: https://ipython.org/ipython-doc/3/notebook/notebook.html
  23. Jupyter Notebook: http://jupyter.org/index.html
  24. PyQt on the Python wiki: https://wiki.python.org/moin/PyQt
  25. PySide on the Qt wiki: http://wiki.qt.io/PySide
  26. Bokeh examples: http://bokeh.pydata.org/en/latest/docs/gallery/periodic.html
  27. CPK color model: https://en.wikipedia.org/wiki/CPK_coloring

The Author

Frank Hofmann (http://www.efho.de) works in Berlin as a service provider at B¸ro 2.0, an open source experts' network specializing in printing and typesetting. Since 2008, he has coordinated the regional meeting of LUGs from the Berlin-Brandenburg Region and is coauthor of the Debian-Paketmanagement-Buch (Debian Package Management Book, http://www.dpmb.org).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Tutorial – Matplotlib

    Matplotlib offers so many options that you may have trouble deciding on which ones to use for your plots.

  • Analytics with Python and KDD

    The Knowledge Discovery in Data Mining (KDD) method breaks the business of data analytics into easy-to-understand steps. We'll show you how to get started with KDD and Python.

  • PyScript

    PyScript lets you use your favorite Python libraries on client-side web pages.

  • Packet Analysis with Scapy

    The Scapy packet manipulation program lets you analyze and manipulate packets to create incident response reports or examine network security.

  • Introduction

    This month in Linux Voice.

comments powered by Disqus