Book Image

Mastering Matplotlib 2.x

By : Benjamin Walter Keller
Book Image

Mastering Matplotlib 2.x

By: Benjamin Walter Keller

Overview of this book

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
Table of Contents (7 chapters)

The basemap methods

Before we get started, let's think a little bit about map projections. We have already seen the visualized data showing population density in the United States:

It is known that the earth is a sphere, but your screen is not a sphere, it's actually a flat Euclidean plane. So, translating points from the surface of a sphere onto the points on the surface of this flat plane is actually non-trivial. We can't unroll a sphere into a flat plane without tearing or distorting that sphere, and so, most of the time when you're dealing with a map, you're actually looking at a projection.

But Mercator is only one of many projections. There are other alternative projections, and even projections that don't necessarily end up giving you square edges for your globe, as shown here:

One of the key things when setting up a map is choosing which...