Matplotlib 3.0 Cookbook

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Build attractive, insightful, and powerful visualizations to gain quality insights from your data

Key Features

  • Master Matplotlib for data visualization
  • Customize basic plots to make and deploy figures in cloud environments
  • Explore recipes to design various data visualizations from simple bar charts to advanced 3D plots

Book Description

Matplotlib provides a large library of customizable plots, along with a comprehensive set of backends. Matplotlib 3.0 Cookbook is your hands-on guide to exploring the world of Matplotlib, and covers the most effective plotting packages for Python 3.7.

With the help of this cookbook, you'll be able to tackle any problem you might come across while designing attractive, insightful data visualizations. With the help of over 150 recipes, you'll learn how to develop plots related to business intelligence, data science, and engineering disciplines with highly detailed visualizations. Once you've familiarized yourself with the fundamentals, you'll move on to developing professional dashboards with a wide variety of graphs and sophisticated grid layouts in 2D and 3D. You'll annotate and add rich text to the plots, enabling the creation of a business storyline. In addition to this, you'll learn how to save figures and animations in various formats for downstream deployment, followed by extending the functionality offered by various internal and third-party toolkits, such as axisartist, axes_grid, Cartopy, and Seaborn.

By the end of this book, you'll be able to create high-quality customized plots and deploy them on the web and on supported GUI applications such as Tkinter, Qt 5, and wxPython by implementing real-world use cases and examples.

What you will learn

  • Develop simple to advanced data visualizations in Matplotlib
  • Use the pyplot API to quickly develop and deploy different plots
  • Use object-oriented APIs for maximum flexibility with the customization of figures
  • Develop interactive plots with animation and widgets
  • Use maps for geographical plotting
  • Enrich your visualizations using embedded texts and mathematical expressions
  • Embed Matplotlib plots into other GUIs used for developing applications
  • Use toolkits such as axisartist, axes_grid1, and cartopy to extend the base functionality of Matplotlib

Who this book is for

The Matplotlib 3.0 Cookbook is for you if you are a data analyst, data scientist, or Python developer looking for quick recipes for a multitude of visualizations. This book is also for those who want to build variations of interactive visualizations.

Downloading the example code for this book You can download the example code files for all 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.

Author(s): Srinivasa Rao Poladi
Edition: 1
Publisher: Packt Publishing
Year: 2018

Language: English
Commentary: Converted
Pages: 676
City: Birmingham
Tags: Programming;Python;Matplotlib;Tkinter;Qt5;wxPython

1: Anatomy of Matplotlib
Introduction
Working in interactive mode
Working in non-interactive mode
Reading from external files and plotting
Changing and resetting default environment variables

2: Getting Started with Basic Plots
Introduction
Line plot
Bar plot
Scatter plot
Bubble plot
Stacked plot
Pie plot
Table chart
Polar plot
Histogram
Box plot
Violin plot
Reading and displaying images
Heatmap
Hinton diagram
Contour plot
Triangulations
Stream plot
Path

3: Plotting Multiple Charts, Subplots, and Figures
Introduction
Plotting multiple graphs on the same axes
Plotting subplots on the same figure
Plotting multiple figures in a session
Logarithmic scale
Using units of measurement

4: Developing Visualizations for Publishing Quality
Introduction
Color, line style, and marker customization
Working with standard colormaps
User-defined colors and colormaps
Working with legend
Customizing labels and titles
Using autoscale and axis limits
Customizing ticks and ticklabels
Customizing spines
Twin axes
Using hatch
Using annotation
Using style sheets

5: Plotting with Object-Oriented API
Introduction
Plotting a correlation matrix using pyplot and object-oriented APIs
Plotting patches using object-oriented API
Plotting collections using object-oriented API

6: Plotting with Advanced Features
Using property cycler
Using Path effects
Using transforms
Taking control of axes positions
GridSpec for figure layout
Using origin and extent for image orientation
Geographical plotting using geopandas

7: Embedding Text and Expressions
Introduction
Using mathematical expressions with a font dictionary
Annotating a point on a polar plot
Using ConnectionPatch
Using a text box
Plotting area under an integral curve
Defining custom markers
Fractions, regular mathematical expressions, and symbols
Word embeddings in two dimensions

8: Saving the Figure in Different Formats
Introduction
Saving the figure in various formats
Avoiding truncation while saving the figure
Saving partial figures
Managing image resolution
Managing transparency for web applications
Creating multi-page PDF reports

9: Developing Interactive Plots
Introduction
Events and callbacks
Widgets
Animation

10: Embedding Plots in a Graphical User Interface
Introduction
Using the Slider and Button Widgets of Matplotlib
Using the Slider and Button widgets of Tkinter GUI
Embedding Matplotlib in a Tkinter GUI application
Using the Slider and Button widgets of WxPython GUI
Embedding Matplotlib in to a wxPython GUI application
Using the Slider and Button widgets of Qt's GUI
Embedding Matplotlib in to a Qt GUI application

11: Plotting 3D Graphs Using the mplot3d Toolkit
Introduction
Line plot
Scatter plot
Bar plot
Polygon plot
Contour plot
Surface plot
Wireframe plot
Triangular surface plot
Plotting 2D data in 3D
3D visualization of linearly non-separable data in 2D
Word embeddings

12: Using the axisartist Toolkit
Introduction
Understanding attributes in axisartist
Defining curvilinear grids in rectangular boxes
Defining polar axes in rectangular boxes
Using floating axes for a rectangular plot
Creating polar axes using floating axes
Plotting planetary system data on floating polar axes

13: Using the axes_grid1 Toolkit
Introduction
Plotting twin axes using the axisartist and axesgrid1 toolkits
Using AxesDivider to plot a scatter plot and associated histograms
Using AxesDivider to plot a colorbar
Using ImageGrid to plot images with a colorbar in a grid
Using inset_locator to zoom in on an image
Using inset_locator to plot inset axes

14: Plotting Geographical Maps Using Cartopy Toolkit
Introduction
Plotting basic map features
Plotting projections
Using grid lines and labels
Plotting locations on the map
Plotting country maps with political boundaries
Plotting country maps using GeoPandas and cartopy
Plotting populated places of the world
Plotting the top five and bottom five populated countries
Plotting temperatures across the globe
Plotting time zones
Plotting an animated map

15: Exploratory Data Analysis Using the Seaborn Toolkit
Introduction
Relational plots
Categorical plots
Distribution plots
Regression plots
Multi-plot grids
Matrix plots