Member-only story
Adding Inset Axes to Matplotlib Figures
A how-to on adding inset axes to a Matplotlib figure to improve your data visualisation
When creating figures in matplotlib, there may be occasions where you want to add a smaller figure or axes inside of your main figure. This could be for a number of reasons, but most commonly, it is used to highlight an area of interest and enlarge it or to include additional information that is related to the main figure.
Matplotlib makes this process very simple by allowing us to add inset axes within the main figure. This can then be further tweaked to get the information we want displayed how we want.
In this short tutorial, we will see how to create a simple well location map, like the one below, using grid coordinates. We will then add inset axes to highlight and enlarge a smaller area of the main map.
Importing Libraries and Loading Data
The first step in our tutorial is to import the libraries we are going to be using.
The first two import statements should be familiar: importing pandas and matplotib. The…