Closed
Description
Bug report
Bug summary
Vertical annotations shrink subplots when a figure handle's tight_layout
is set to True. The expectation is that annotations would overlap the subplots.
Looking at the documentation...
https://matplotlib.org/3.2.2/tutorials/intermediate/tight_layout_guide.html#caveats
tight_layout() only considers ticklabels, axis labels, and titles. Thus, other artists may be clipped and also may overlap
With that in mind, tight_layout
should not consider Text
annotations, and shouldn't adjust the subplot size when added.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,np.pi*2,1000)
y = np.sin(x)
dy = np.cos(x)
dy2 = -np.sin(x)
for b in [False,True]:
h, ax = plt.subplots(3,1,sharex = True)
h.set_tight_layout(b)
ax[0].plot(x,y)
ax[1].plot(x,dy)
ax[2].plot(x,dy2)
ax[2].annotate(s = f'Annotation When Tight Layout is {b}', xy = (np.pi,-1), rotation = 'vertical')
Actual outcome
Expected outcome
In this case, tight_layout
is set to FALSE just to see visually what it looks like with the text overlayed
Matplotlib version
- Operating system: CentOS Linux 7 (Core)
- Matplotlib version: 3.2.2
- Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.8.3
- Jupyter version (if applicable):
- Other libraries: numpy 1.18.5
conda
conda-forge