Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
Vertical annotations shrink subplots when a figure handle'stight_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 considerText
annotations, and shouldn't adjust the subplot size when added.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnpx=np.linspace(0,np.pi*2,1000)y=np.sin(x)dy=np.cos(x)dy2=-np.sin(x)forbin [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