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
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.
Expected outcome
What is expected is a properly spaced areas with the proper extent. This can be produced when usingadd_subplot
instead ofadd_subfigure
.
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