Chapter 6. Data Visualization

One of the first steps in data analysis is visualization. Even when looking at a table of values, we can form a mental image of what the data might look like when graphed. Data visualization calls for the conception and analysis of the visual representation of information, signifying data that has been abstracted in some formal pattern, including properties or quantities for units of measurements of the data. Data visualization is tightly associated with scientific visualization and statistical graphics. The Python matplotlib (all lowercase) library is a well-known plotting library based on NumPy, which we will be using in this chapter. It has an object-oriented and a procedural MATLAB-like API, which can be used in parallel. A gallery with matplotlib examples can be found at http://matplotlib.org/gallery.html. The following is a list of topics that will be covered in this chapter:

  • Basic matplotlib plots
  • Logarithmic plots
  • Scatter plots
  • Legends and annotations
  • Three-dimensional plots
  • Plotting in pandas
  • Lag plots
  • Autocorrelation plots
  • Plot.ly

matplotlib subpackages

If we pick up our pkg_check.py file provided in the code bundle and change the code to list the matplotlib subpackages, we get the following result:

matplotlib version 1.3.1
matplotlib.axes
matplotlib.backends
matplotlib.compat
matplotlib.delaunay DESCRIPTION :Author: Robert Kern <[email protected]> :Copyright: Copyright 2005 Robert Kern. :License: BSD-style license. See LICENSE.tx
matplotlib.projections
matplotlib.sphinxext
matplotlib.style
matplotlib.testing
matplotlib.tests
matplotlib.tri

The subpackage names are pretty self-explanatory. Backends refers to the way the end result is output. This can be one of several file formats or on the screen in a graphical user interface. For completeness, refer to the following snippet with the changed lines in pkg_check.py:

import matplotlib as mpl

print "matplotlib version", mpl.__version__

print_desc("matplotlib", mpl.__path__)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.196