This notebook presents a working example of adjusting texts for multiple subplots, related to https://github.com/Phlya/adjustText/issues/58

[1]:
%matplotlib inline
import matplotlib.pyplot as plt
from adjustText import adjust_text
import numpy as np
import pandas as pd
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.

With multiple subplots, run adjust_text for one subplot at a time

[2]:
fig, axes = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True)
axes = axes.ravel()

for k, ax in enumerate(axes):
    np.random.seed(0)
    x, y = np.random.random((2,30))
    ax.plot(x, y, 'bo')

    texts = []
    for i in range(len(x)):
        t = ax.text(x[i], y[i], 'Text%s' %i, ha='center', va='center')
        texts.append(t)
    adjust_text(texts, ax=ax)
_images/Examples-for-multiple-subplots_3_0.png
[ ]: