1818
1919import matplotlib as mpl
2020from matplotlib import _api , _pylab_helpers , _tight_layout
21+ from matplotlib ._api import UNSET as _UNSET
2122from matplotlib .transforms import Bbox
2223
2324_log = logging .getLogger (__name__ )
@@ -366,7 +367,8 @@ def __init__(self, nrows, ncols, figure=None,
366367
367368 _AllowedKeys = ["left" , "bottom" , "right" , "top" , "wspace" , "hspace" ]
368369
369- def update (self , ** kwargs ):
370+ def update (self , * , left = _UNSET , bottom = _UNSET , right = _UNSET , top = _UNSET ,
371+ wspace = _UNSET , hspace = _UNSET ):
370372 """
371373 Update the subplot parameters of the grid.
372374
@@ -377,15 +379,23 @@ def update(self, **kwargs):
377379 ----------
378380 left, right, top, bottom : float or None, optional
379381 Extent of the subplots as a fraction of figure width or height.
380- wspace, hspace : float, optional
382+ wspace, hspace : float or None , optional
381383 Spacing between the subplots as a fraction of the average subplot
382384 width / height.
383385 """
384- for k , v in kwargs .items ():
385- if k in self ._AllowedKeys :
386- setattr (self , k , v )
387- else :
388- raise AttributeError (f"{ k } is an unknown keyword" )
386+ if left is not _UNSET :
387+ self .left = left
388+ if bottom is not _UNSET :
389+ self .bottom = bottom
390+ if right is not _UNSET :
391+ self .right = right
392+ if top is not _UNSET :
393+ self .top = top
394+ if wspace is not _UNSET :
395+ self .wspace = wspace
396+ if hspace is not _UNSET :
397+ self .hspace = hspace
398+
389399 for figmanager in _pylab_helpers .Gcf .figs .values ():
390400 for ax in figmanager .canvas .figure .axes :
391401 if ax .get_subplotspec () is not None :
0 commit comments