Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Python Data Visualization Cookbook (Second Edition)
Python Data Visualization Cookbook (Second Edition)

Python Data Visualization Cookbook (Second Edition): Visualize data using Python's most popular libraries

Arrow left icon
Profile Icon Igor Milovanovic Profile Icon Giuseppe Vettigli Profile Icon Foures
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (6 Ratings)
Paperback Nov 2015 302 pages 1st Edition
eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Igor Milovanovic Profile Icon Giuseppe Vettigli Profile Icon Foures
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (6 Ratings)
Paperback Nov 2015 302 pages 1st Edition
eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Python Data Visualization Cookbook (Second Edition)

Chapter 1. Preparing Your Working Environment

In this chapter, you will cover the following recipes:

  • Installing matplotlib, NumPy, and SciPy
  • Installing virtualenv and virtualenvwrapper
  • Installing matplotlib on Mac OS X
  • Installing matplotlib on Windows
  • Installing Python Imaging Library (PIL) for image processing
  • Installing a requests module
  • Customizing matplotlib's parameters in code
  • Customizing matplotlib's parameters per project

Introduction

This chapter introduces the reader to the essential tooling and their installation and configuration. This is necessary work and a common base for the rest of the book. If you have never used Python for data and image processing and visualization, it is advised not to skip this chapter. Even if you do skip it, you can always return to this chapter in case you need to install some supporting tools or verify what version you need to support the current solution.

Installing matplotlib, NumPy, and SciPy

This chapter describes several ways of installing matplotlib and required dependencies under Linux.

Getting ready

We assume that you already have Linux (preferably Debian/Ubuntu or RedHat/SciLinux) installed and Python installed on it. Usually, Python is already installed on the mentioned Linux distributions and, if not, it is easily installable through standard means. We assume that Python 2.7+ Version is installed on your workstation.

Note

Almost all code should work with Python 3.3+ Versions, but since most operating systems still deliver Python 2.7 (some even Python 2.6), we decided to write the Python 2.7 Version code. The differences are small, mainly in the version of packages and some code (xrange should be substituted with range in Python 3.3+).

We also assume that you know how to use your OS package manager in order to install software packages and know how to use a terminal.

The build requirements must be satisfied before matplotlib can be built.

matplotlib requires NumPy, libpng, and freetype as build dependencies. In order to be able to build matplotlib from source, we must have installed NumPy. Here's how to do it:

Install NumPy (1.5+ if you want to use it with Python 3) from http://www.numpy.org/

NumPy will provide us with data structures and mathematical functions for using it with large datasets. Python's default data structures such as tuples, lists, or dictionaries are great for insertions, deletions, and concatenation. NumPy's data structures support "vectorized" operations and are very efficient for use and for executions. They are implemented with big data in mind and rely on C implementations that allow efficient execution time.

Note

SciPy, building on top of NumPy, is the de facto standard's scientific and numeric toolkit for Python comprising a great selection of special functions and algorithms, most of them actually implemented in C and Fortran, coming from the well-known Netlib repository (http://www.netlib.org).

Perform the following steps for installing NumPy:

  1. Install the Python-NumPy package:
    sudo apt-get install python-numpy
    
  2. Check the installed version:
    $ python -c 'import numpy; print numpy.__version__'
    
  3. Install the required libraries:
    • libpng 1.2: PNG files support (requires zlib)
    • freetype 1.4+: True type font support
    $ sudo apt-get build-dep python-matplotlib
    

    If you are using RedHat or a variation of this distribution (Fedora, SciLinux, or CentOS), you can use yum to perform the same installation:

    $ su -c 'yum-builddep python-matplotlib'
    

How to do it...

There are many ways one can install matplotlib and its dependencies: from source, precompiled binaries, OS package manager, and with prepackaged Python distributions with built-in matplotlib.

Most probably the easiest way is to use your distribution's package manager. For Ubuntu that should be:

# in your terminal, type:
$ sudo apt-get install python-numpy python-matplotlib python-scipy

If you want to be on the bleeding edge, the best option is to install from source. This path comprises a few steps: get the source code, build requirements, and configure, compile, and install.

Download the latest source from code host SourceForge by following these steps:

$ cd ~/Downloads/
$ wget https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.tar.gz
$ tar xzf matplotlib-1.4.3.tar.gz
$ cd matplotlib-1.4.3
$ python setup.py build
$ sudo python setup.py install

Tip

Downloading the example code

You can download the example code files for all the Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

How it works...

We use standard Python Distribution Utilities, known as Distutils, to install matplotlib from the source code. This procedure requires us to previously install dependencies, as we already explained in the Getting ready section of this recipe. The dependencies are installed using the standard Linux packaging tools.

There's more...

There are more optional packages that you might want to install depending on what your data visualization projects are about.

No matter what project you are working on, we recommend installing IPython—an Interactive Python shell where you already have matplotlib and related packages, such as NumPy and SciPy, imported and ready to play with. Please refer to IPython's official site on how to install it and use it—it is, though, very straightforward.

Installing virtualenv and virtualenvwrapper

If you are working on many projects simultaneously, or even just switching between them frequently, you'll find that having everything installed system-wide is not the best option and can bring problems in future on different systems (production) where you want to run your software. This is not a good time to find out that you are missing a certain package or you're having versioning conflicts between packages that are already installed on production system; hence, virtualenv.

virtualenv is an open source project started by Ian Bicking that enables a developer to isolate working environments per project, for easier maintenance of different package versions.

For example, you inherited legacy Django website based on Django 1.1 and Python 2.3, but at the same time you are working on a new project that must be written in Python 2.6. This is my usual case—having more than one required Python version (and related packages)—depending on the project I am working on.

virtualenv enables me to easily switch between different environments and have the same package easily reproduced if I need to switch to another machine or to deploy software to a production server (or to a client's workstation).

Getting ready

To install virtualenv, you must have a workable installation of Python and pip. Pip is a tool for installing and managing Python packages, and it is a replacement for easy_install. We will use pip through most of this book for package management. Pip is easily installed, as root executes the following line in your terminal:

# easy_install pip

virtualenv by itself is really useful, but with the help of virtualenvwrapper, all this becomes easy to do and also easy to organize many virtual environments. See all the features at http://virtualenvwrapper.readthedocs.org/en/latest/#features.

How to do it...

By performing the following steps, you can install the virtualenv and virtualenvwrapper tools:

  1. Install virtualenv and virtualenvwrapper:
    $ sudo pip install virtualenv
    $ sudo pip install virtualenvwrapper
    # Create folder to hold all our virtual environments and export the path to it.
    $ export VIRTENV=~/.virtualenvs
    $ mkdir -p $VIRTENV
    # We source (ie. execute) shell script to activate the wrappers
    $ source /usr/local/bin/virtualenvwrapper.sh
    # And create our first virtual environment
    $ mkvirtualenv virt1
    
  2. You can now install our favorite package inside virt1:
    (virt1)user1:~$ pip install matplotlib
    
  3. You will probably want to add the following line to your ~/.bashrc file:
    source /usr/loca/bin/virtualenvwrapper.sh
    

A few useful and most frequently used commands are as follows:

  • mkvirtualenv ENV: This creates a virtual environment with the name ENV and activates it
  • workon ENV: This activates the previously created ENV
  • deactivate: This gets us out of the current virtual environment

pip not only provides you with a practical way of installing packages, but it also is a good solution for keeping track of the python packages installed on your system, as well as their version. The command pip freeze will print all the installed packages on your current environment, followed by their version number:

$ pip freeze
matplotlib==1.4.3
mock==1.0.1
nose==1.3.6
numpy==1.9.2
pyparsing==2.0.3
python-dateutil==2.4.2
pytz==2015.2
six==1.9.0
wsgiref==0.1.2

In this case, we see that even though we simply installed matplotlib, many other packages are also installed. Apart from wsgiref, which is used by pip itself, these are required dependencies of matplotlib which have been automatically installed.

When transferring a project from an environment (possibly a virtual environment) to another, the receiving environment needs to have all the necessary packages installed (in the same version as in the original environment) in order to be sure that the code can be properly run. This can be problematic as two different environments might not contain the same packages, and, worse, might contain different versions of the same package. This can lead to conflicts or unexpected behaviors in the execution of the program.

In order to avoid this problem, pip freeze can be used to save a copy of the current environment configuration. The command will save the output of the command to the file requirements.txt:

$ pip freeze > requirements.txt

In a new environment, this file can be used to install all the required libraries. Simply run:

$ pip install -r requirements.txt

All the necessary packages will automatically be installed in their specified version. That way, we ensure that the environment where the code is used is always the same. This is a good practice to have a virtual environment and a requirements.txt file for every project you are developing. Therefore, before installing the required packages, it is advised that you first create a new virtual environment to avoid conflicts with other projects.

The overall workflow from one machine to another is therefore:

  • On machine 1:
    $ mkvirtualenv env1
    (env1)$ pip install matplotlib
    (env1)$ pip freeze > requirements.txt
    
  • On machine 2:
    $ mkvirtualenv env2
    (env2)$ pip install -r requirements.txt
    

Installing matplotlib on Mac OS X

The easiest way to get matplotlib on the Mac OS X is to use prepackaged python distributions such as Enthought Python Distribution (EPD). Just go to the EPD site, and download and install the latest stable version for your OS.

In case you are not satisfied with EPD or cannot use it for other reasons such as the versions distributed with it, there is a manual (read: harder) way of installing Python, matplotlib, and its dependencies.

Getting ready

We will use the Homebrew (you could also use MacPorts in the same way) project that eases the installation of all software that Apple did not install on your OS, including Python and matplotlib. Under the hood, Homebrew is a set of Ruby and Git that automate download and installation. Following these instructions should get the installation working. First, we will install Homebrew, and then Python, followed by tools such as virtualenv, then dependencies for matplotlib (NumPy and SciPy), and finally matplotlib. Hold on, here we go.

How to do it...

  1. In your terminal, paste and execute the following command:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    After the command finishes, try running brew update or brew doctor to verify that the installation is working properly.

  2. Next, add the Homebrew directory to your system path, so the packages you install using Homebrew have greater priority than other versions. Open ~/.bash_profile (or /Users/[your-user-name]/.bash_profile) and add the following line to the end of file:
    export PATH=/usr/local/bin:$PATH
    
  3. You will need to restart the terminal so that it picks a new path. Installing Python is as easy as firing up another one liner:
    brew install python --framework --universal

    This will also install any prerequisites required by Python.

  4. Now, you need to update your path (add to the same line):
    export PATH=/usr/local/share/python:/usr/local/bin:$PATH
  5. To verify that the installation has worked, type python --version in the command line, you should see 2.7.3 as the version number in the response.
  6. You should have pip installed by now. In case it is not installed, use easy_install to add pip:
    $ easy_install pip
    
  7. Now, it's easy to install any required package; for example, virtualenv and virtualenvwrapper are useful:
    pip install virtualenv
    pip install virtualenvwrapper
    
  8. The next step is what we really wanted to do all along—install matplotlib:
    pip install numpy
    brew install gfortran
    pip install scipy
    
  9. Verify that everything is working. Call Python and execute the following commands:
    import numpy
    print numpy.__version__
    import scipy
    print scipy.__version__
    quit()
    
  10. Install matplotlib:
    pip install matplotlib
    

Installing matplotlib on Windows

In this recipe, we will demonstrate how to install Python and start working with matplotlib installation. We assume Python was not previously installed.

Getting ready

There are two ways of installing matplotlib on Windows. The easiest way is by installing prepackaged Python environments, such as EPD, Anaconda, SageMath, and Python(x,y). This is the suggested way to install Python, especially for beginners.

The second way is to install everything using binaries of precompiled matplotlib and required dependencies. This is more difficult as you have to be careful about the versions of NumPy and SciPy you are installing, as not every version is compatible with the latest version of matplotlib binaries. The advantage in this is that you can even compile your particular versions of matplotlib or any library to have the latest features, even if they are not provided by authors.

How to do it...

The suggested way of installing free or commercial Python scientific distributions is as easy as following the steps provided on the project's website.

If you just want to start using matplotlib and don't want to be bothered with Python versions and dependencies, you may want to consider using the Enthought Python Distribution (EPD). EPD contains prepackaged libraries required to work with matplotlib and all the required dependencies (SciPy, NumPy, IPython, and more).

As usual, we download Windows installer (*.exe) that will install all the code we need to start using matplotlib and all recipes from this book.

There is also a free scientific project Python(x,y) (http://python-xy.github.io) for Windows 32-bit system that contains all dependencies resolved, and is an easy (and free!) way of installing matplotlib on Windows. Since Python(x,y) is compatible with Python modules installers, it can be easily extended with other Python libraries. No Python installation should be present on the system before installing Python(x,y).

Let me shortly explain how we would install matplotlib using precompiled Python, NumPy, SciPy, and matplotlib binaries:

  1. First, we download and install standard Python using the official .msi installer for our platform (x86 or x86-64).
  2. After that, download official binaries for NumPy and SciPy and install them first.
  3. When you are sure that NumPy and SciPy are properly installed. Then, we download the latest stable release binary for matplotlib and install it by following the official instructions.

There's more...

Note that many examples are not included in the Windows installer. If you want to try the demos, download the matplotlib source and look in the examples subdirectory.

Installing Python Imaging Library (PIL) for image processing

Python Imaging Library (PIL) enables image processing using Python. It has an extensive file format support and is powerful enough for image processing.

Some popular features of PIL are fast access to data, point operations, filtering, image resizing, rotation, and arbitrary affine transforms. For example, the histogram method allows us to get statistics about the images.

PIL can also be used for other purposes, such as batch processing, image archiving, creating thumbnails, conversion between image formats, and printing images.

PIL reads a large number of formats, while write support is (intentionally) restricted to the most commonly used interchange and presentation formats.

How to do it...

The easiest and most recommended way is to use your platform's package managers. For Debian and Ubuntu use the following commands:

$ sudo apt-get build-dep python-imaging
$ sudo pip install http://effbot.org/downloads/Imaging-1.1.7.tar.gz

How it works...

This way we are satisfying all build dependencies using the apt-get system but also installing the latest stable release of PIL. Some older versions of Ubuntu usually don't provide the latest releases.

On RedHat and SciLinux systems, run the following commands:

# yum install python-imaging
# yum install freetype-devel
# pip install PIL

There's more...

There is a good online handbook, specifically, for PIL. You can read it at http://www.pythonware.com/library/pil/handbook/index.htm or download the PDF version from http://www.pythonware.com/media/data/pil-handbook.pdf.

There is also a PIL fork, Pillow, whose main aim is to fix installation issues. Pillow can be found at http://pypi.python.org/pypi/Pillow and it is easy to install (at the time of writing, Pillow is the only choice if you are using OS X).

On Windows, PIL can also be installed using a binary installation file. Install PIL in your Python site-packages by executing .exe from http://www.pythonware.com/products/pil/.

Now, if you want PIL used in a virtual environment, manually copy the PIL.pth file and the PIL directory at C:\Python27\Lib\site-packages to your virtualenv site-packages directory.

Installing a requests module

Most of the data that we need now is available over HTTP or similar protocol, so we need something to get it. Python library requests make the job easy.

Even though Python comes with the urllib2 module for work with remote resources and supporting HTTP capabilities, it requires a lot of work to get the basic tasks done.

A requests module brings a new API that makes the use of web services seamless and pain free. Lots of the HTTP 1.1 stuff is hidden away and exposed only if you need it to behave differently than default.

How to do it...

Using pip is the best way to install requests. Use the following command for the same:

$ pip install requests

That's it. This can also be done inside your virtualenv, if you don't need requests for every project or want to support different requests versions for each project.

Just to get you ahead quickly, here's a small example on how to use requests:

import requests
r = requests.get('http://github.com/timeline.json')
print r.content

How it works...

We sent the GET HTTP request to a URI at www.github.com that returns a JSON-formatted timeline of activity on GitHub (you can see HTML version of that timeline at https://github.com/timeline). After the response is successfully read, the r object contains content and other properties of the response (response code, cookies set, header metadata, and even the request we sent in order to get this response).

Customizing matplotlib's parameters in code

The library we will use the most throughout this book is matplotlib; it provides the plotting capabilities. Default values for most properties are already set inside the configuration file for matplotlib, called .rc file. This recipe describes how to modify matplotlib properties from our application code.

Getting ready

As we already said, matplotlib configuration is read from a configuration file. This file provides a place to set up permanent default values for certain matplotlib properties, well, for almost everything in matplotlib.

How to do it...

There are two ways to change parameters during code execution: using the dictionary of parameters (rcParams) or calling the matplotlib.rc() command. The former enables us to load an already existing dictionary into rcParams, while the latter enables a call to a function using a tuple of keyword arguments.

If we want to restore the dynamically changed parameters, we can use matplotlib.rcdefaults() call to restore the standard matplotlib settings.

The following two code samples illustrate previously explained behaviors:

  • An example for matplotlib.rcParams:
    import matplotlib as mpl
    mpl.rcParams['lines.linewidth'] = 2
    mpl.rcParams['lines.color'] = 'r'
    
  • An example for the matplotlib.rc() call:
    import matplotlib as mpl
    mpl.rc('lines', linewidth=2, color='r')
    

Both examples are semantically the same. In the second sample, we define that all subsequent plots will have lines with line width of 2 points. The last statement of the previous code defines that the color of every line following this statement will be red, unless we override it by local settings. See the following example:

import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.0, 1.0, 0.01)

s = np.sin(2 * np.pi * t)
# make line red
plt.rcParams['lines.color'] = 'r'
plt.plot(t,s)

c = np.cos(2 * np.pi * t)
# make line thick
plt.rcParams['lines.linewidth'] = '3'
plt.plot(t,c)

plt.show()

How it works…

First, we import matplotlib.pyplot and NumPy to allow us to draw sine and cosine graphs. Before plotting the first graph, we explicitly set the line color to red using the plt.rcParams['lines.color'] = 'r' command.

Next, we go to the second graph (cosine function) and explicitly set the line width to three points using the plt.rcParams['lines.linewidth'] = '3' command.

If we want to reset specific settings, we should call matplotlib.rcdefaults().

In this recipe, we have seen how to customize the style of a matplotlib chart dynamically changing its configuration parameters. The matplotlib.rcParams object is the interface that we used to modify the parameters. It's global to the matplotlib packages and any change that we apply to it affects all the charts that we draw after.

Customizing matplotlib's parameters per project

This recipe explains where the various configuration files are that matplotlib uses and why we want to use one or the other. Also, we explain what is in these configuration files.

Getting ready

If you don't want to configure matplotlib as the first step in your code every time you use it (as we did in the previous recipe), this recipe will explain how to have different default configurations of matplotlib for different projects. This way your code will not be cluttered with configuration data and, moreover, you can easily share configuration templates with your co-workers or even among other projects.

How to do it...

If you have a working project that always uses the same settings for certain parameters in matplotlib, you probably don't want to set them every time you want to add a new graph code. Instead, what you want is a permanent file, outside of your code, which sets defaults for matplotlib parameters.

matplotlib supports this via its matplotlibrc configuration file that contains most of the changeable properties of matplotlib.

How it works...

There are three different places where this file can reside and its location defines its usage. They are:

  • Current working directory: This is where your code runs from. This is the place to customize matplotlib just for your current directory that might contain your current project code. The file is named matplotlibrc.
  • Per user .matplotlib/matplotlibrc: This is usually in the user's $HOME directory (under Windows, this is your Documents and Settings directory). You can find out where your configuration directory is using the matplotlib.get_configdir() command. Check the next command.
  • Per installation configuration file: This is usually in your Python site-packages. This is a system-wide configuration, but it will get overwritten every time you reinstall matplotlib; so, it is better to use a per user configuration file for more persistent customizations. The best usage so far for me was to use this as a default template, if I mess up my user's configuration file or if I need fresh configuration to customize for a different project.

The following one liner will print the location of your configuration directory and can be run from shell:

$ python -c 'import matplotlib as mpl; print mpl.get_configdir()'

The configuration file contains settings for:

  • axes: This deals with face and edge color, tick sizes, and grid display.
  • backend: This sets the target output: TkAgg and GTKAgg.
  • figure: This deals with dpi, edge color, figure size, and subplot settings.
  • font: This looks at font families, font size, and style settings.
  • grid: This deals with grid color and line settings.
  • legend: This specifies how legends and text inside will be displayed.
  • lines: This checks for line (color, style, width, and so on) and markers settings.
  • patch: These patches are graphical objects that fill 2D space, such as polygons and circles; set linewidth, color, antialiasing, and so on.
  • savefig: There are separate settings for saved figures. For example, to make rendered files with a white background.
  • text: This looks for text color, how to interpret text (plain versus latex markup) and similar.
  • verbose: This checks how much information matplotlib gives during runtime: silent, helpful, debug, and debug annoying.
  • xticks and yticks: These set the color, size, direction, and label size for major and minor ticks for the x and y axes.

There's more...

If you are interested in more details for every mentioned setting (and some that we did not mention here), the best place to go is the website of the matplotlib project where there is up-to-date API documentation. If it doesn't help, user and development lists are always good places to leave questions. See the back of this book for useful online resources.

Left arrow icon Right arrow icon

Key benefits

  • Learn how to set up an optimal Python environment for data visualization
  • Understand how to import, clean and organize your data
  • Determine different approaches to data visualization and how to choose the most appropriate for your needs

Description

Python Data Visualization Cookbook will progress the reader from the point of installing and setting up a Python environment for data manipulation and visualization all the way to 3D animations using Python libraries. Readers will benefit from over 60 precise and reproducible recipes that will guide the reader towards a better understanding of data concepts and the building blocks for subsequent and sometimes more advanced concepts. Python Data Visualization Cookbook starts by showing how to set up matplotlib and the related libraries that are required for most parts of the book, before moving on to discuss some of the lesser-used diagrams and charts such as Gantt Charts or Sankey diagrams. Initially it uses simple plots and charts to more advanced ones, to make it easy to understand for readers. As the readers will go through the book, they will get to know about the 3D diagrams and animations. Maps are irreplaceable for displaying geo-spatial data, so this book will also show how to build them. In the last chapter, it includes explanation on how to incorporate matplotlib into different environments, such as a writing system, LaTeX, or how to create Gantt charts using Python.

Who is this book for?

If you already know about Python programming and want to understand data, data formats, data visualization, and how to use Python to visualize data then this book is for you.

What you will learn

  • Introduce yourself to the essential tooling to set up your working environment.
  • Explore your data using the capabilities of standard Python Data Library and Panda Library
  • Draw your first chart and customize it
  • Use the most popular data visualization Python libraries
  • Make 3D visualizations mainly using mplot3d
  • Create charts with images and maps
  • Understand the most appropriate charts to describe your data
  • Know the matplotlib hidden gems
  • Use plot.ly to share your visualization online

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 30, 2015
Length: 302 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396695
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Nov 30, 2015
Length: 302 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396695
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 146.97
Python Data Visualization Cookbook (Second Edition)
$48.99
Learning Data Mining with Python
$48.99
Python Machine Learning
$48.99
Total $ 146.97 Stars icon

Table of Contents

10 Chapters
1. Preparing Your Working Environment Chevron down icon Chevron up icon
2. Knowing Your Data Chevron down icon Chevron up icon
3. Drawing Your First Plots and Customizing Them Chevron down icon Chevron up icon
4. More Plots and Customizations Chevron down icon Chevron up icon
5. Making 3D Visualizations Chevron down icon Chevron up icon
6. Plotting Charts with Images and Maps Chevron down icon Chevron up icon
7. Using the Right Plots to Understand Data Chevron down icon Chevron up icon
8. More on matplotlib Gems Chevron down icon Chevron up icon
9. Visualizations on the Clouds with Plot.ly Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(6 Ratings)
5 star 66.7%
4 star 0%
3 star 0%
2 star 33.3%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Reader May 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very clear recipes and explanations, everything I hoped it would be.
Amazon Verified review Amazon
Oleg Okun Jan 16, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The title of this book includes the word "cookbook" and as a cookbook the book contains a plenty of practical recipes of data visualization in Python. It presents not a mere description of Python packages and commands related to visualization, but embeds these tools into real-world scenarios. Not only visualization itself but also data manipulation enabling insightful visualization are discussed in detail. Needless to say, the discussion of every topic is accompanied by ready-to-use Python code.
Amazon Verified review Amazon
Amazon Customer Dec 07, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book helped me to understand how to visualize data with python anf find a good solution to implement own little datamart at home for home automation project.
Amazon Verified review Amazon
Amazon Customer Dec 31, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I received a free copy of this book in exchange for my review. I think this is a great book. The examples for the different plotting methods and customizations all worked. The first chapter describe set-up and code samples for using data in different formats. I remember when I was first given the task to add a chart to a report to represent data and how it took me a minute to ensure I was doing things correctly. This book would helped me a great deal at that time. Many questions I had previously about plotting and correctly coding solutions for charts I haven't been asked to make yet, were answered. I have been creating reports and charts for a University Research team and this book has been a godsend. I think this book would have helped me when I was working using java for reports and charts. I just this is a great book.
Amazon Verified review Amazon
Jonathan Jul 14, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Please don"t get me wrong, the book is quite useful and it"s quite frankly more handy for me to look things up in a book than on the internet.But in essence, all the information is freely available on the internet and therefore the book is very, very expensive for a black-and-white handbook!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.