Overview

Matplotlib 3.4, released on March 27, 2021, introduces subfigures for complex layouts and adds font fallback for better multilingual rendering.

Main Features

Subfigures

Subfigures allow creating nested figures, each with its own subplots and titles. This is ideal for complex layouts with per-section legends.

python
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure(figsize=(10, 5))
subfigs = fig.subfigures(1, 2)

# Left subfigure
subfigs[0].suptitle('Raw data')
ax = subfigs[0].subplots(2, 1)
ax[0].plot(np.random.randn(100))
ax[1].plot(np.random.randn(100), 'r')

# Right subfigure
subfigs[1].suptitle('Histograms')
ax2 = subfigs[1].subplots(2, 1)
ax2[0].hist(np.random.randn(500), bins=20)
ax2[1].hist(np.random.randn(500), bins=20, color='orange')

plt.show()

Font fallback

The font fallback system allows Matplotlib to automatically search for missing characters in other fonts, improving multilingual text rendering without manual configuration.

python
import matplotlib.pyplot as plt

# Font fallback automatically handles characters
# from different scripts
fig, ax = plt.subplots()
ax.set_title('International Sales')
countries = ['France', '日本', 'Deutschland', '中国']
sales = [120, 95, 110, 150]
ax.bar(countries, sales)
plt.show()

Sources