Mastering Matplotlib 2.x

Book description

Understand and build beautiful and advanced plots with Matplotlib and Python

Key Features

  • Practical guide with hands-on examples to design interactive plots
  • Advanced techniques to constructing complex plots
  • Explore 3D plotting and visualization using Jupyter Notebook

Book Description

In this book, you'll get hands-on with customizing your data plots with the help of Matplotlib. You'll start with customizing plots, making a handful of special-purpose plots, and building 3D plots. You'll explore non-trivial layouts, Pylab customization, and more about tile configuration. You'll be able to add text, put lines in plots, and also handle polygons, shapes, and annotations. Non-Cartesian and vector plots are exciting to construct, and you'll explore them further in this book. You'll delve into niche plots and visualize ordinal and tabular data. In this book, you'll be exploring 3D plotting, one of the best features when it comes to 3D data visualization, along with Jupyter Notebook, widgets, and creating movies for enhanced data representation. Geospatial plotting will also be explored. Finally, you'll learn how to create interactive plots with the help of Jupyter.

Learn expert techniques for effective data visualization using Matplotlib 3 and Python with our latest offering -- Matplotlib 3.0 Cookbook

What you will learn

  • Deal with non-trivial and unusual plots
  • Understanding Basemap methods
  • Customize and represent data in 3D
  • Construct Non-Cartesian and vector plots
  • Design interactive plots using Jupyter Notebook
  • Make movies for enhanced data representation

Who this book is for

This book is aimed at individuals who want to explore data visualization techniques. A basic knowledge of Matplotlib and Python is required.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Matplotlib 2.x
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the author
    2. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Heavy Customization
    1. Customizing PyLab using style
      1. How to use styles to change the appearance of our plots
      2. Different Matplotlib styles
      3. Creating your own styles
    2. Deep diving into color
      1. Questions to ask when choosing a color map
      2. Using color maps
    3. Working on non-trivial layouts
    4. The Matplotlib configuration files
      1. Matplotlibrc – where does it live?
    5. Summary
  7. Drawing on Plots
    1. Putting lines in place
      1. Adding horizontal and vertical lines
      2. Adding spans that cover whole regions
      3. Adding and tweaking a background grid
    2. Adding text on your plots
      1. Adding text to both axis and figure objects
      2. Adding text in multi-panel figures
    3. Playing with polygons and shapes
      1. Adding polygons and shapes to our plots
      2. The built-in shapes that Matplotlib provides
      3. Building your own polygons
    4. Versatile annotating
      1. Adding arrows to our plots with the annotate method
      2. Adding some text to the arrows
      3. Customizing the appearance of the annotations
    5. Summary
  8. Special Purpose Plots
    1. Non-Cartesian plots
      1. Creating polar axes
      2. Applying log, symmetric log, and logistic scales to your axes
    2. Plotting vector fields
      1. Making vector plots with quiver
      2. Customizing the appearance of vector plots
      3. Annotating vector plots with a quiver key
      4. Making stream plots
    3. Statistics with boxes and violins
      1. Making box plots to show the interquartile ranges and the outliers
      2. Making violin plots show different distributions
      3. Customizing the appearance of plots
    4. Visualizing ordinal and tabular data
      1. Pie charts
      2. Tables
      3. Customizing the appearance of plots
    5. Summary
  9. 3D and Geospatial Plots
    1. Plotting with 3D axes
      1. How to add 3D axes to a figure
      2. How to use the interactive backend to manipulate the 3D plots
      3. How to plot on the 3D axes
    2. Looking at various 3D plot types
      1. How to rotate the camera in 3D plots
      2. How to add line and scatter plots
      3. How to add wireframe, surface, and triangular surface plots
      4. How to add 3D contour types
    3. The basemap methods
      1. How to create map projections
      2. How to choose between different kinds of map projections
      3. Further reading
    4. Plotting on map projections
      1. How to add simple points and lines to our plots
      2. How to draw great circles
      3. How to draw a day/night terminator
    5. Adding geography
      1. How to add coastline and water features
      2. How to add political boundaries for countries, states, and provinces
    6. Summary
  10. Interactive Plotting
    1. Interactive plots in the Jupyter Notebook
      1. How to install and enable the ipywidgets module
      2. How to use the interact method to make basic widgets
      3. How to view the different kinds of widgets that ipywidgets provides
      4. How to customize widgets
    2. Event handling with plot callbacks
      1. How to add interactivity by capturing mouse events
      2. How to capture keyboard clicks
      3. How to use the picker to manipulate plots
    3. GUI neutral widgets
      1. How to add the basic GUI neutral widgets
      2. A selection of the different kinds of widgets that are available in Matplotlib
      3. How to add interactivity to these widgets using callbacks
    4. Making movies
      1. How to generate animations to make plots that update themselves
      2. How to customize the animation frame rate, speed, and repetitions
      3. How to save animations as mp4 videos and animated GIFs
    5. Summary
  11. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering Matplotlib 2.x
  • Author(s): Benjamin Walter Keller
  • Release date: November 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789617696