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]:constrained_layout merging similar subgrids #22143

Closed
Labels
topic: geometry managerLayoutEngine, Constrained layout, Tight layout
Milestone
@malfatti

Description

@malfatti

Bug summary

When plotting a figure withconstrained_layout and subgrids, rows with the same arguments are being plot on top of each other.

Code for reproduction

importmatplotlib.pyplotaspltFig=plt.figure(constrained_layout=True)GS=Fig.add_gridspec(3,1)GSRows=  [GS[0].subgridspec(1,5,width_ratios=(0.2,1,1,1,0.2)),GS[1].subgridspec(1,5,width_ratios=(0.2,1,0.2,1,1)),GS[2].subgridspec(1,5,width_ratios=(0.2,1,1,1,0.2)),# GS[2].subgridspec(1,5, width_ratios=(0.199999, 1, 1, 1, 0.2)),]Axes= [Fig.add_subplot(GSRows[0][1]),Fig.add_subplot(GSRows[0][2]),Fig.add_subplot(GSRows[0][3]),Fig.add_subplot(GSRows[1][1]),Fig.add_subplot(GSRows[1][3]),Fig.add_subplot(GSRows[1][4]),Fig.add_subplot(GSRows[2][1]),Fig.add_subplot(GSRows[2][2]),Fig.add_subplot(GSRows[2][3]),]Fig.savefig('ActualOutcome.jpg')# Fig.savefig('ExpectedOutcome.jpg')plt.show()

Actual outcome

ActualOutcome

Expected outcome

(Changed the third row first column width ratio from 0.2 to 0.199999, see commented line)
ExpectedOutcome

Additional information

In the example, the figure has 3 rows and 5 columns with different width ratios. Rows 1 and 3 have the same width ratios, while row 2 has a different width ratio. Note that rows 1 and 3 are merged (row 3 is drawn on top of row 1; Actual outcome image). Note also that if the subgrids are all different (see commented lines in code example changing the width ratio of row 3 from 0.2 to 0.199999) all three rows are drawn as expected.

This was not the case at least until3.4.3, where even if the rows are equal, they are drawn at their expected places.

Operating system

Gentoo

Matplotlib Version

3.5.1

Matplotlib Backend

TkAgg

Python version

Python 3.9.9

Jupyter version

6.4.6

Installation

Linux package manager

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: geometry managerLayoutEngine, Constrained layout, Tight layout

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp