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 summary
fig.tight_layout is broken in current matplotlib.
Code for reproduction
%pylabplot([0,1])tight_layout()# happens same way in object modefrommatplotlibimportpylabaspltfig,ax=plt.subplots()ax.plot([0,1])fig.tight_layout()
Actual outcome
below another example from real code that may be instructive
Expected outcome
figure scaled to image size, background deleted.
Additional information
Happens always.
I do not recall this issue in version before 3.5
I have no clue why it is happening. The flaw seems to lay in mpl getting/setting wrong window size when using tight_layout. Maybe gtk unhappy with X11. When I usempl.use('Qt5Cairo')
then it just makes the windowand fonts smaller. Obviously,tight_layout
should not change physical window size on screen! Similar for Gtk4Cairo.Gtk4Agg
has similar issues toQt5Agg
but does not retain noise in background, just shrinks figure. I could be related to DPI settings. It might get them from a different system call than when opening the window?
The only fix I can find is use other plot package, e.g., plotly.
Operating system
Linux 5.16.14-200.fc35.x86_64#1 SMP PREEMPT Fri Mar 11 20:31:18 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Matplotlib Version
3.5.1
Matplotlib Backend
Qt5Agg
Python version
Python 3.10.2
Jupyter version
N/A
Installation
pip