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