SciPy 2023

Mosaic Magic with Matplotlib
07-10, 08:00–12:00 (America/Chicago), Classroom 101

Communicating scientific data often relies on making comparisons between multiple datasets.
Join the Matplotlib team to learn about creating multi-axis figures to display such data side-by-side.
This intermediate level tutorial will cover a variety of tools for making multi-axis figures.
Of particular focus will be the subplot_mosaic and the layout engines: tight, constrained, and compressed.
This tutorial will emphasize the use of Matplotlib's Object Oriented (OO) API and why that is generally recommended over the pyplot (plt) API.


This tutorial is designed for users of Matplotlib who want to learn more about how to lay out complicated figures.
Bring a figure you like that you want to replicate the layout of or one that you'd like to improve.

  • Introduction (10 mins)
  • Parts of a figure. What makes up a figure (20 mins)
  • (Build up to: https://matplotlib.org/stable/gallery/showcase/anatomy.html)
  • Creating a figure with a single axes (10 mins)
  • Object oriented model of interacting with axes (20 mins)
    • e.g. Prefer ax.plot over plt.plot
  • Multi axes figures (~1.5 hr):
    • subplots (10 mins)
    • subplot_mosaic (30 mins)
    • grid_spec (20 mins)
    • subplot2grid (5 mins)
    • add_axes (5 mins)
    • add_subplot (5 mins)
    • Inset and zoomed axes (5 mins)
  • Layout engines (30 mins)
    • Introduction (10 mins)
    • Constrained Layout (10 mins)
    • Compressed Layout (5 mins)
    • Tight Layout (5 mins)
  • Labeling figures (20 mins)
    • Axis/figure labels (10 mins)
    • Legends (5 mins)
    • Colorbars (5 mins)
  • Subfigures (10 mins)
  • Conclusions/questions (20 mins)

Detailed setup instructions will be provided prior to the event.


Installation Instructions

https://github.com/ksunden/mosaic_magic_with_matplotlib

Prerequisites

It is expected that participants will have some prior knowledge of Matplotlib, but not necessarily prior knowledge of making particularly complex figures.

Kyle is a Research Software Engineer working for Matplotlib with a focus on the data pipeline.
Kyle has a PhD in Chemistry from the University of Wisconsin where he made software to control laser spectroscopy instrumentation.