Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: tight_layout (version 3.5+) #22673

Closed
Labels
Milestone
@2sn

Description

@2sn

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

xxx

below another example from real code that may be instructive

xxx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp