You are previewing Python Data Visualization Cookbook.
O'Reilly logo
Python Data Visualization Cookbook

Book Description

As a developer with knowledge of Python you are already in a great position to start using data visualization. This superb cookbook shows you how in plain language and practical recipes, culminating with 3D animations.

  • Learn how to set up an optimal Python environment for data visualization

  • Understand the topics such as importing data for visualization and formatting data for visualization

  • Understand the underlying data and how to use the right visualizations

  • In Detail

    Today, data visualization is a hot topic as a direct result of the vast amount of data created every second. Transforming that data into information is a complex task for data visualization professionals, who, at the same time, try to understand the data and objectively transfer that understanding to others. This book is a set of practical recipes that strive to help the reader get a firm grasp of the area of data visualization using Python and its popular visualization and data libraries.

    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 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 you 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. During the book, we go from simple plots and charts to more advanced ones, thoroughly explaining why we used them and how not to use them. As we go through the book, we will also discuss 3D diagrams. We will peep into animations just to show you what it takes to go into that area. Maps are irreplaceable for displaying geo-spatial data, so we also show you how to build them. In the last chapter, we show you how to incorporate matplotlib into different environments, such as a writing system, LaTeX, or how to create Gantt charts using Python.

    This book will help those who already know how to program in Python to explore a new field – one of data visualization. As this book is all about recipes that explain how to do something, code samples are abundant, and they are followed by visual diagrams and charts to help you understand the logic and compare your own results with what is explained in the book.

    Table of Contents

    1. Python Data Visualization Cookbook
      1. Table of Contents
      2. Python Data Visualization Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewers
      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. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. 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 datafiles
          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 data from a database
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Cleaning up data from outliers
          1. Getting ready
          2. How to do it...
          3. There's more...
        10. Reading files in chunks
          1. How to do it...
          2. How it works...
          3. There's more...
        11. Reading streaming data sources
          1. How to do it...
          2. How it works...
          3. There's more...
        12. Importing image data into NumPy arrays
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        13. Generating controlled random datasets
          1. Getting ready
          2. How to do it...
        14. 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 a simple sine and cosine plot
          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 a legend 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. 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...
      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...
            1. Using Pyglet Quickstart
            2. Using Glumpy Quickstart
            3. Pyprocessing introduction
      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 an image 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 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 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 a 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 a 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 errorbars
          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. Index