O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering matplotlib

Book Description

A practical guide that takes you beyond the basics of matplotlib and gives solutions to plot complex data

  • Customize, configure, and handle events, and interact with figures using matplotlib
  • Create highly intricate and complicated graphs using matplotlib
  • Explore matplotlib's depths through examples and explanations in IPython notebooks

In Detail

matplotlib is a Python plotting library that provides a large feature set for a multitude of platforms. Given the depth of the library's legacy and the variety of related open source projects, gaining expert knowledge can be a time-consuming and often confusing process.

You'll begin your exciting journey learning about the skills that are necessary in leading technical teams for a visualization project or to become a matplotlib contributor.

Supported by highly-detailed IPython Notebooks, this book takes you through the conceptual components underlying the library and then provides a detailed overview of its APIs. From there, you will learn about event handling and how to code for interactive plots.

Next you will move on to customization techniques, local configuration of matplotib, and then deployments in Cloud environments. The adventure culminates in an exploration of big data visualization and matplotlib clustering.

What You Will Learn

  • Analyze the matplotlib code base and its internals
  • Re-render visualized data on the fly based on changes in the user interface
  • Take advantage of sophisticated third-party libraries to plot complex data relationships
  • Create custom styles for use in specialize publications, presentations, or online media
  • Generate consolidated master plots comprising many subplots for dashboard-like results
  • Deploy matplotlib in Cloud environments
  • Utilize matplotlib in big data projects

Table of Contents

  1. Mastering matplotlib
    1. Table of Contents
    2. Mastering matplotlib
    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. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Getting Up to Speed
      1. A brief historical overview of matplotlib
      2. What's new in matplotlib 1.4
      3. The intermediate matplotlib user
      4. Prerequisites for this book
      5. Python 3
      6. Coding style
      7. Installing matplotlib
      8. Using IPython Notebooks with matplotlib
      9. Advanced plots – a preview
      10. Setting up the interactive backend
        1. Joint plots with Seaborn
        2. Scatter plot matrix graphs with Pandas
      11. Summary
    9. 2. The matplotlib Architecture
      1. The original design goals
      2. The current matplotlib architecture
      3. The backend layer
        1. FigureCanvasBase
        2. RendererBase
        3. Event
        4. Visualizing the backend layer
      4. The artist layer
        1. Primitives
        2. Containers
        3. Collections
        4. A view of the artist layer
      5. The scripting layer
      6. The supporting components of the matplotlib stack
      7. matplotlib modules
        1. Exploring the filesystem
        2. Exploring imports visually
          1. ModuleFinder
          2. ModGrapher
      8. The execution flow
        1. An overview of the script
        2. An interactive session
      9. The matplotlib architecture as it relates to this book
      10. Summary
    10. 3. matplotlib APIs and Integrations
      1. The procedural pylab API
      2. The pyplot scripting API
      3. The matplotlib object-oriented API
        1. Equations
        2. Helper classes
        3. The Plotter class
        4. Running the jobs
      4. matplotlib in other frameworks
        1. An important note on IPython
      5. Summary
    11. 4. Event Handling and Interactive Plots
      1. Event loops in matplotlib
        1. Event-based systems
        2. The event loop
        3. GUI toolkit main loops
        4. IPython Notebook event loops
        5. matplotlib event loops
      2. Event handling
        1. Mouse events
        2. Keyboard events
        3. Axes and figure events
        4. Object picking
        5. Compound event handling
          1. The navigation toolbar
          2. Specialized events
          3. Interactive panning and zooming
      3. Summary
    12. 5. High-level Plotting and Data Analysis
      1. High-level plotting
        1. Historical background
        2. matplotlib
        3. NetworkX
        4. Pandas
        5. The grammar of graphics
        6. Bokeh
        7. The ŷhat ggplot
        8. New styles in matplotlib
        9. Seaborn
      2. Data analysis
        1. Pandas, SciPy, and Seaborn
        2. Examining and shaping a dataset
        3. Analysis of temperature
        4. Analysis of precipitation
      3. Summary
    13. 6. Customization and Configuration
      1. Customization
        1. Creating a custom style
        2. Subplots
          1. Revisiting Pandas
          2. Individual plots
          3. Bringing everything together
        3. Further explorations in customization
      2. Configuration
        1. The run control for matplotlib
          1. File and directory locations
          2. Using the matplotlibrc file
          3. Updating the settings dynamically
        2. Options in IPython
      3. Summary
    14. 7. Deploying matplotlib in Cloud Environments
      1. Making a use case for matplotlib in the Cloud
        1. The data source
        2. Defining a workflow
        3. Choosing technologies
          1. Configuration management
          2. Types of deployment
      2. An example – AWS and Docker
        1. Getting set up locally
          1. Requirements
        2. Dockerfiles and the Docker images
          1. Extending a Docker image
          2. Building a new image
        3. Preparing for deployment
        4. Getting the setup on AWS
          1. Pushing the source data to S3
          2. Creating a host server on EC2
          3. Using Docker on EC2
          4. Reading and writing with S3
        5. Running the task
          1. Environment variables and Docker
          2. Changes to the Python module
          3. Execution
      3. Summary
    15. 8. matplotlib and Big Data
      1. Big data
      2. Working with large data sources
        1. An example problem
        2. Big data on the filesystem
          1. NumPy's memmap function
          2. HDF5 and PyTables
        3. Distributed data
          1. MapReduce
          2. Open source options
          3. An example – working with data on EMR
      3. Visualizing large data
        1. Finding the limits of matplotlib
        2. Agg rendering with matplotlibrc
        3. Decimation
        4. Additional techniques
      4. Other visualization tools
      5. Summary
    16. 9. Clustering for matplotlib
      1. Clustering and parallel programming
      2. The custom ZeroMQ cluster
        1. Estimating the value of π
        2. Creating the ZeroMQ components
        3. Working with the results
      3. Clustering with IPython
        1. Getting started
        2. The direct view
        3. The load-balanced view
        4. The parallel magic functions
        5. An example – estimating the value of π
      4. More clustering
      5. Summary
    17. Index