Closed
Description
Bug summary
Offset notation on the y-axis creates a "+1" or similar marker that overlaps a long title.
Code for reproduction
import matplotlib.pyplot as plt
import random
random.seed(123)
x = [n for n in range(100)]
y = [1 + random.random()/1000 for _ in range(100)]
fig, ax = plt.subplots()
ax.plot(x, y, '.-', label="random values near 1.0")
ax.set_title('abcdefghijklmnopqrstuvwxyz' + ' test ' + ' abcdefghijklmnopqrstuvwxyz')
ax.set_ylabel("y")
ax.set_xlabel("x")
ax.legend()
fig.savefig("example.png")
plt.show()
Actual outcome
Expected outcome
Additional information
There are workarounds such as passing arguments like y=1.03
or pad=15
to set_title()
to push the title up manually. However, this should not be necessary as the documentation says "y is determined automatically to avoid decorators on the Axes" (see pull request #17127). Note also that setting constrained_layout=True
does not change the output.
Operating system
Windows 10
Matplotlib Version
3.4.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.9.7
Jupyter version
6.4.5
Installation
conda