Python Data Visualization Cookbook - Second Edition

Book description

Over 70 recipes to get you started with popular Python libraries based on the principal concepts of data visualization

About This Book

  • 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

Who This Book Is 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

In Detail

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.

Style and approach

A step-by-step recipe based approach to data visualization. The topics are explained sequentially as cookbook recipes consisting of a code snippet and the resulting visualization.

Table of contents

  1. Python Data Visualization Cookbook Second Edition
    1. Table of Contents
    2. Python Data Visualization Cookbook Second Edition
    3. Credits
    4. About the Authors
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Preparing Your Working Environment
      1. Introduction
      2. Installing matplotlib, NumPy, and SciPy
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Installing virtualenv and virtualenvwrapper
        1. Getting ready
        2. How to do it...
      4. Installing matplotlib on Mac OS X
        1. Getting ready
        2. How to do it...
      5. Installing matplotlib on Windows
        1. Getting ready
        2. How to do it...
        3. There's more...
      6. Installing Python Imaging Library (PIL) for image processing
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Installing a requests module
        1. How to do it...
        2. How it works...
      8. Customizing matplotlib's parameters in code
        1. Getting ready
        2. How to do it...
        3. How it works…
      9. Customizing matplotlib's parameters per project
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    9. 2. Knowing Your Data
      1. Introduction
      2. Importing data from CSV
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Importing data from Microsoft Excel files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Importing data from fixed-width data files
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Importing data from tab-delimited files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Importing data from a JSON resource
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Exporting data to JSON, CSV, and Excel
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      8. Importing and manipulating data with Pandas
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      9. Importing data from a database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      10. Cleaning up data from outliers
        1. Getting ready
        2. How to do it...
        3. There's more...
      11. Reading files in chunks
        1. How to do it...
        2. How it works...
        3. There's more...
      12. Reading streaming data sources
        1. How to do it...
        2. How it works...
        3. There's more...
      13. Importing image data into NumPy arrays
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      14. Generating controlled random datasets
        1. Getting ready
        2. How to do it...
      15. Smoothing the noise in real-world data
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    10. 3. Drawing Your First Plots and Customizing Them
      1. Introduction
      2. Defining plot types – bar, line, and stacked charts
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Drawing simple sine and cosine plots
        1. Getting ready
        2. How to do it...
      4. Defining axis lengths and limits
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Defining plot line styles, properties, and format strings
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Color
          2. Background color
      6. Setting ticks, labels, and grids
        1. Getting ready
        2. How to do it...
      7. Adding legends and annotations
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Moving spines to the center
        1. How to do it...
        2. How it works...
        3. There's more...
      9. Making histograms
        1. Getting ready
        2. How to do it...
        3. How it works...
      10. Making bar charts with error bars
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      11. Making pie charts count
        1. Getting ready
        2. How to do it...
      12. Plotting with filled areas
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      13. Making stacked plots
        1. Getting ready
        2. How to do it...
        3. How it works...
      14. Drawing scatter plots with colored markers
        1. Getting ready
        2. How to do it...
        3. How it works...
    11. 4. More Plots and Customizations
      1. Introduction
      2. Setting the transparency and size of axis labels
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Adding a shadow to the chart line
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Adding a data table to the figure
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Using subplots
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Customizing grids
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Creating contour plots
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Filling an under-plot area
        1. Getting ready
        2. How to do it...
        3. How it works...
      9. Drawing polar plots
        1. Getting ready
        2. How to do it...
        3. How it works...
      10. Visualizing the filesystem tree using a polar bar
        1. Getting ready
        2. How to do it...
        3. How it works...
      11. Customizing matplotlib with style
        1. Getting ready
        2. How to do it...
        3. How it works...
    12. 5. Making 3D Visualizations
      1. Introduction
      2. Creating 3D bars
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Creating 3D histograms
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Animating in matplotlib
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Animating with OpenGL
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    13. 6. Plotting Charts with Images and Maps
      1. Introduction
      2. Processing images with PIL
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Plotting with images
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Displaying images with other plots in the figure
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Plotting data on a map using Basemap
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Plotting data on a map using the Google Map API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Generating CAPTCHA images
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    14. 7. Using the Right Plots to Understand Data
      1. Introduction
      2. Understanding logarithmic plots
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Understanding spectrograms
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Creating stem plot
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Drawing streamlines of vector flow
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Using colormaps
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Using scatter plots and histograms
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      8. Plotting the cross correlation between two variables
        1. Getting ready
        2. How to do it...
        3. How it works...
      9. Importance of autocorrelation
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    15. 8. More on matplotlib Gems
      1. Introduction
      2. Drawing barbs
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Making a box-and-whisker plot
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Making Gantt charts
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Making error bars
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Making use of text and font properties
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Rendering text with LaTeX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      8. Understanding the difference between pyplot and OO API
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    16. 9. Visualizations on the Clouds with Plot.ly
      1. Introduction
      2. Creating line charts
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Creating bar charts
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Plotting a 3D trefoil knot
        1. How to do it...
        2. How it works...
      5. Visualizing maps and bubbles
        1. Getting ready
        2. How to do it...
        3. How it works...
    17. Index

Product information

  • Title: Python Data Visualization Cookbook - Second Edition
  • Author(s): Igor Milovanović, Dimitry Foures, Giuseppe Vettigli
  • Release date: November 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781784396695