Sitemap
Data Science Collective

Advice, insights, and ideas from the Medium data science community

Member-only story

Six Matplotlib Changes That Improve Your Figures for Reporting and Publication

9 min readMay 16, 2026

--

Press enter or click to view image in full size

It’s no secret that matplotlib’s defaults are functional, but they don’t always do the data justice! I have talked about this multiple times on here and over on Substack.

You’ll get a chart with the right data, the right axes, and roughly the right shape. But functional and clear aren’t the same thing, and the distance between them is mostly a handful of lines of code and personal choices.

This article covers six of them. They are not clever hacks, instead they are small adjustments that can become automatic once you’ve made them a few times.

The example I am using here is synthetic porosity-permeability scatter for four lithology types: Sand A, Sand B, Shaly Sand, and Tight Zone. Whilst this article is geoscience focused, the same changes can be applied to any chart to take them from matplotlib basic to something that you can easily put in a report.

Setting Up the Basic Matplotlib Plot

The starting point is a plain scatter with no styling decisions at all.

fig, ax = plt.subplots()

for formation, group in df.groupby("Formation"):
ax.scatter(group["Porosity"]…

--

--

Andy McDonald
Andy McDonald

Written by Andy McDonald

Petrophysicist and Data Scientist with a passion for data analytics, machine learning, and AI. More on my Substack: https://andymcdonaldgeo.substack.com/

Data Science Collective
Data Science Collective

Published in Data Science Collective

Advice, insights, and ideas from the Medium data science community