@@ -123,7 +123,7 @@ def __init__(self, *, pad=1.08, h_pad=None, w_pad=None,
123123 h_pad, w_pad : float
124124 Padding (height/width) between edges of adjacent subplots.
125125 Defaults to *pad*.
126- rect : tuple[float, float, float, float] , optional
126+ rect : tuple of 4 floats , optional
127127 (left, bottom, right, top) rectangle in normalized figure
128128 coordinates that the subplots (including labels)
129129 will fit into. Defaults to using the entire figure.
@@ -179,7 +179,8 @@ class ConstrainedLayoutEngine(LayoutEngine):
179179 _colorbar_gridspec = False
180180
181181 def __init__ (self , * , h_pad = None , w_pad = None ,
182- hspace = None , wspace = None , ** kwargs ):
182+ hspace = None , wspace = None , rect = (0 , 0 , 1 , 1 ),
183+ ** kwargs ):
183184 """
184185 Initialize ``constrained_layout`` settings.
185186
@@ -197,15 +198,20 @@ def __init__(self, *, h_pad=None, w_pad=None,
197198 If h/wspace < h/w_pad, then the pads are used instead.
198199 Default to :rc:`figure.constrained_layout.hspace` and
199200 :rc:`figure.constrained_layout.wspace`.
201+ rect : tuple of 4 floats
202+ Rectangle in figure coordinates to perform constrained layout in
203+ (left, bottom, width, height), each from 0-1.
200204 """
201205 super ().__init__ (** kwargs )
202206 # set the defaults:
203207 self .set (w_pad = mpl .rcParams ['figure.constrained_layout.w_pad' ],
204208 h_pad = mpl .rcParams ['figure.constrained_layout.h_pad' ],
205209 wspace = mpl .rcParams ['figure.constrained_layout.wspace' ],
206- hspace = mpl .rcParams ['figure.constrained_layout.hspace' ])
210+ hspace = mpl .rcParams ['figure.constrained_layout.hspace' ],
211+ rect = (0 , 0 , 1 , 1 ))
207212 # set anything that was passed in (None will be ignored):
208- self .set (w_pad = w_pad , h_pad = h_pad , wspace = wspace , hspace = hspace )
213+ self .set (w_pad = w_pad , h_pad = h_pad , wspace = wspace , hspace = hspace ,
214+ rect = rect )
209215
210216 def execute (self , fig ):
211217 """
@@ -222,10 +228,11 @@ def execute(self, fig):
222228
223229 return do_constrained_layout (fig , w_pad = w_pad , h_pad = h_pad ,
224230 wspace = self ._params ['wspace' ],
225- hspace = self ._params ['hspace' ])
231+ hspace = self ._params ['hspace' ],
232+ rect = self ._params ['rect' ])
226233
227234 def set (self , * , h_pad = None , w_pad = None ,
228- hspace = None , wspace = None ):
235+ hspace = None , wspace = None , rect = None ):
229236 """
230237 Set the pads for constrained_layout.
231238
@@ -243,6 +250,9 @@ def set(self, *, h_pad=None, w_pad=None,
243250 If h/wspace < h/w_pad, then the pads are used instead.
244251 Default to :rc:`figure.constrained_layout.hspace` and
245252 :rc:`figure.constrained_layout.wspace`.
253+ rect : tuple of 4 floats
254+ Rectangle in figure coordinates to perform constrained layout in
255+ (left, bottom, width, height), each from 0-1.
246256 """
247257 for td in self .set .__kwdefaults__ :
248258 if locals ()[td ] is not None :
0 commit comments