Skip to content

Commit a82a512

Browse files
committed
Permit passing update() args to gridspec.copy()
1 parent e69fd04 commit a82a512

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

proplot/gridspec.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,18 @@ def __init__(self, nrows=1, ncols=1, **kwargs):
229229
proplot.figure.Figure.add_subplots
230230
matplotlib.gridspec.GridSpec
231231
232-
Note
233-
----
232+
Important
233+
---------
234234
Adding axes panels, axes or figure colorbars, and axes or figure legends
235-
quietly augments the gridspec geometry by inserting "panel slots". However
235+
quietly augments the gridspec geometry by inserting "panel slots". However,
236236
subsequently indexing the gridspec with ``gs[num]`` or ``gs[row, col]`` will
237237
ignore the "panel slots". This permits adding new subplots by passing
238238
``gs[num]`` or ``gs[row, col]`` to `~proplot.figure.Figure.add_subplot`
239-
even in the presence of panels. See `~GridSpec.__getitem__` for details.
239+
even in the presence of panels (see `~GridSpec.__getitem__` for details).
240+
This also means that each `GridSpec` is `~proplot.figure.Figure`-specific,
241+
i.e. it can only be used once (if you are working with `GridSpec` instances
242+
manually and want the same geometry for multiple figures, you must create
243+
a copy with `GridSpec.copy` before working on the subsequent figure).
240244
"""
241245
# Gridspec properties
242246
self._nrows = nrows
@@ -990,11 +994,19 @@ def _assign_vector(key, values, space):
990994
_assign_vector('hratios', hratios, space=False)
991995
_assign_vector('wratios', wratios, space=False)
992996

993-
def copy(self):
997+
@docstring._snippet_manager
998+
def copy(self, **kwargs):
994999
"""
995-
Return a copy of the `GridSpec` with rows and columns allocated
996-
for "panel" subplots removed. This can be useful when drawing
997-
multiple `~proplot.figure.Figure`\\ s with the same geometry.
1000+
Return a copy of the `GridSpec` with the `~proplot.figure.Figure`-specific
1001+
"panel slots" removed. This can be useful if you want to draw multiple
1002+
figures with the same geometry. Properties are inherited from this
1003+
`GridSpec` by default but can be changed by passing keyword arguments.
1004+
1005+
Parameters
1006+
----------
1007+
%(gridspec.shared)s
1008+
%(gridspec.vector)s
1009+
%(gridspec.tight)s
9981010
9991011
See also
10001012
--------
@@ -1023,6 +1035,7 @@ def copy(self):
10231035
):
10241036
value = getattr(self, '_' + key)
10251037
setattr(gs, '_' + key, value)
1038+
gs.update(**kwargs)
10261039
return gs
10271040

10281041
def get_geometry(self):

0 commit comments

Comments
 (0)