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]: add_subfigure does not respect GridSpec parameters #28132

Open
@nawendt

Description

@nawendt

Bug summary

According the documentation forFigure.add_subfigure, you should be able to useGridSpec to create a set of subfigures to fill a certain space of a parent figure. However, no matter what settings are input intoGridSpec, the parent figure is divided into equally sized subfigures. Doing this same process withFigure.add_subplot produces the expected results with the axes bounded by the input extent and separated by the correcthspace andwspace.

Code for reproduction

importmatplotlib.pyplotaspltfrommatplotlib.gridspecimportGridSpecimportnumpyasnpdpi=100width=600height=600main=plt.figure(figsize=(width/dpi,height/dpi),dpi=100,facecolor='#9a9a9a',frameon=False)gs=GridSpec(2,4,left=.1,right=.9,bottom=0.1,top=0.9,wspace=0.15,hspace=0.15)colors=np.array([    ['red','black','green','blue'],    ['brown','gray','white','gold']])panels= []forrowinrange(2):forcolinrange(4):main.add_subfigure(gs[row,col],facecolor=colors[row][col])plt.show()

Actual outcome

The output is equally sized subfigures without any space between them and the full extent being used despite the input restrictions.
test_add_subfig

Expected outcome

What is expected is a properly spaced areas with the proper extent. This can be produced when usingadd_subplot instead ofadd_subfigure.
test_add_subplot

Additional information

No response

Operating system

No response

Matplotlib Version

3.8.3

Matplotlib Backend

No response

Python version

3.12.2

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp