Overview

Matplotlib 3.8, released on September 14, 2023, improves style sheets and adds new layout options.

Main Features

Improved style sheets

Built-in style sheets are improved with better color gradients and crisper rendering.

python
import matplotlib.pyplot as plt
import numpy as np

plt.style.use('seaborn-v0_8-whitegrid')
x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x), label='sin(x)')
plt.plot(x, np.cos(x), label='cos(x)')
plt.legend()
plt.show()

subplot_mosaic layout

The subplot_mosaic method creates complex subplot layouts intuitively.

python
import matplotlib.pyplot as plt

fig, axs = plt.subplot_mosaic(
    [['A', 'B'],
     ['C', 'C']],
    figsize=(8, 6),
)
axs['A'].set_title('Chart A')
axs['B'].set_title('Chart B')
axs['C'].set_title('Chart C (wide)')
plt.show()

Sources