Skip to content

Commit ef9e418

Browse files
committed
Make GridSpec.update docstring match behavior.
The sentence "If any kwarg is None, default to the current value, if set, otherwise to rc." is clearly wrong given the lines just below, which overwrite the current value unconditonally: for k, v in kwargs.items(): if k in self._AllowedKeys: setattr(self, k, v) This can also be checked with e.g. from matplotlib.gridspec import GridSpec from matplotlib import pyplot as plt gs = GridSpec(1, 1, left=.5) gs.update(left=None) plt.figure().add_subplot(gs[0, 0]) plt.show() where the update reset left to the rc value. Given that the behavior has been like that ever since gridspec was added to matplotlib, it seems better to update the docstring.
1 parent af8a720 commit ef9e418

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/matplotlib/gridspec.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,15 @@ def __setstate__(self, state):
255255

256256
def update(self, **kwargs):
257257
"""
258-
Update the current values. If any kwarg is None, default to
259-
the current value, if set, otherwise to rc.
260-
"""
258+
Update the current values.
261259
260+
Values set to None use the rcParams value.
261+
"""
262262
for k, v in kwargs.items():
263263
if k in self._AllowedKeys:
264264
setattr(self, k, v)
265265
else:
266-
raise AttributeError("%s is unknown keyword" % (k,))
267-
266+
raise AttributeError(f"{k} is an unknown keyword")
268267
for figmanager in _pylab_helpers.Gcf.figs.values():
269268
for ax in figmanager.canvas.figure.axes:
270269
# copied from Figure.subplots_adjust

0 commit comments

Comments
 (0)