@@ -172,78 +172,58 @@ class SubplotParams:
172
172
def __init__ (self , left = None , bottom = None , right = None , top = None ,
173
173
wspace = None , hspace = None ):
174
174
"""
175
- All dimensions are fractions of the figure width or height.
176
175
Defaults are given by :rc:`figure.subplot.[name]`.
177
176
178
177
Parameters
179
178
----------
180
179
left : float
181
- The left side of the subplots of the figure.
182
-
180
+ The position of the left edge of the subplots,
181
+ as a fraction of the figure width.
183
182
right : float
184
- The right side of the subplots of the figure.
185
-
183
+ The position of the right edge of the subplots,
184
+ as a fraction of the figure width.
186
185
bottom : float
187
- The bottom of the subplots of the figure.
188
-
186
+ The position of the bottom edge of the subplots,
187
+ as a fraction of the figure height.
189
188
top : float
190
- The top of the subplots of the figure.
191
-
189
+ The position of the top edge of the subplots,
190
+ as a fraction of the figure height.
192
191
wspace : float
193
- The amount of width reserved for space between subplots,
194
- expressed as a fraction of the average axis width.
195
-
192
+ The width of the padding between subplots,
193
+ as a fraction of the average axis width.
196
194
hspace : float
197
- The amount of height reserved for space between subplots,
198
- expressed as a fraction of the average axis height.
195
+ The height of the padding between subplots,
196
+ as a fraction of the average axis height.
199
197
"""
200
198
self .validate = True
199
+ for key in ["left" , "bottom" , "right" , "top" , "wspace" , "hspace" ]:
200
+ setattr (self , key , rcParams [f"figure.subplot.{ key } " ])
201
201
self .update (left , bottom , right , top , wspace , hspace )
202
202
203
203
def update (self , left = None , bottom = None , right = None , top = None ,
204
204
wspace = None , hspace = None ):
205
205
"""
206
206
Update the dimensions of the passed parameters. *None* means unchanged.
207
207
"""
208
- thisleft = getattr (self , 'left' , None )
209
- thisright = getattr (self , 'right' , None )
210
- thistop = getattr (self , 'top' , None )
211
- thisbottom = getattr (self , 'bottom' , None )
212
- thiswspace = getattr (self , 'wspace' , None )
213
- thishspace = getattr (self , 'hspace' , None )
214
-
215
- self ._update_this ('left' , left )
216
- self ._update_this ('right' , right )
217
- self ._update_this ('bottom' , bottom )
218
- self ._update_this ('top' , top )
219
- self ._update_this ('wspace' , wspace )
220
- self ._update_this ('hspace' , hspace )
221
-
222
- def reset ():
223
- self .left = thisleft
224
- self .right = thisright
225
- self .top = thistop
226
- self .bottom = thisbottom
227
- self .wspace = thiswspace
228
- self .hspace = thishspace
229
-
230
208
if self .validate :
231
- if self . left >= self .right :
232
- reset ()
209
+ if (( left if left is not None else self .left )
210
+ >= ( right if right is not None else self . right )):
233
211
raise ValueError ('left cannot be >= right' )
234
-
235
- if self .bottom >= self .top :
236
- reset ()
212
+ if ((bottom if bottom is not None else self .bottom )
213
+ >= (top if top is not None else self .top )):
237
214
raise ValueError ('bottom cannot be >= top' )
238
-
239
- def _update_this (self , s , val ):
240
- if val is None :
241
- val = getattr (self , s , None )
242
- if val is None :
243
- key = 'figure.subplot.' + s
244
- val = rcParams [key ]
245
-
246
- setattr (self , s , val )
215
+ if left is not None :
216
+ self .left = left
217
+ if right is not None :
218
+ self .right = right
219
+ if bottom is not None :
220
+ self .bottom = bottom
221
+ if top is not None :
222
+ self .top = top
223
+ if wspace is not None :
224
+ self .wspace = wspace
225
+ if hspace is not None :
226
+ self .hspace = hspace
247
227
248
228
249
229
class Figure (Artist ):
0 commit comments