Enrich Matplotlib Plots with Inset Axis

Guide the viewer’s attention.

A few days back, we discussed an incredible technique to make plots more appealing using Matplotlib annotations.

Here’s the visual from that post for a quick recap:

If you want to revisit it, here’s the link: Enrich Matplotlib Plots with Annotations.

You can read it after reading this newsletter issue.

Today, let me share another way I frequently use to improve my data visualizations.

Why care?

While creating data visualizations, there are often certain parts that are particularly important.

Yet, they may not be immediately obvious to the viewer.

A good data storyteller always ensures that the plot guides the viewer’s attention to these key areas.

One great way is to zoom in on specific regions of interest in a plot, as depicted below.

In contrast to the usual plot, the other plot guides the viewer’s attention to a specific area of interest.

Such efforts always ensure that the plot communicates what we intend it to depict — even if the plot’s creator is not present at that time.

In matplotlib, we can do so using indicate_inset_zoom(). It adds an indicator box, which can be zoomed-in for better clarity.

The embedded plot is treated like any other matplotlib plot. Thus, we can add axis labels to it, if needed.

Isn’t that an incredible way to make data visualization much more appealing?

👉 Over to you: What are some other underrated ways to improve default plots?

Thanks for reading!

Are you preparing for ML/DS interviews or want to upskill at your current job?

Every week, I publish in-depth ML dives. The topics align with the practical skills that typical ML/DS roles demand.

Join below to unlock all full articles:

Here are some of the top articles:

Join below to unlock all full articles:

👉 If you love reading this newsletter, share it with friends!

👉 Tell the world what makes this newsletter special for you by leaving a review here :)

Reply

or to participate.