8000 Prepare to change the default pad for AxesDivider.append_axes. · matplotlib/matplotlib@c4b37e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4b37e5

Browse files
committed
Prepare to change the default pad for AxesDivider.append_axes.
Using a nonzero default (configurable from the rcParams and identical to what `plt.subplots()` use) should make this method a bit more user-friendly (note that *none* of the uses of `append_axes` throughout the codebase leaves `pad` to its current default of zero).
1 parent 28e32c6 commit c4b37e5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Deprecations
2+
````````````
3+
4+
Passing a ``pad`` size of ``None`` (the default) as a synonym for zero to
5+
the ``append_axes``, ``new_horizontal`` and ``new_vertical`` methods of
6+
`.axes_grid1.axes_divider.AxesDivider` is deprecated. In a future release, the
7+
default value of ``None`` will mean "use :rc:`figure.subplot.wspace` or
8+
:rc:`figure.subplot.hspace`" (depending on the orientation). Explicitly pass
9+
``pad=0`` to keep the old behavior.

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,17 @@ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
530530
If False, the new axes is appended at the end
531531
of the list, i.e., it became the right-most axes. If True, it is
532532
inserted at the start of the list, and becomes the left-most axes.
533-
kwargs
533+
**kwargs
534534
All extra keywords arguments are passed to the created axes.
535535
If *axes_class* is given, the new axes will be created as an
536536
instance of the given class. Otherwise, the same class of the
537537
main axes will be used.
538538
"""
539+
if pad is None:
540+
cbook.warn_deprecated(
541+
"3.2", message="In a future version, 'pad' will default to "
542+
"rcParams['figure.subplot.wspace']. Set pad=0 to keep the "
543+
"old behavior.)
539544
if pad:
540545
if not isinstance(pad, Size._Base):
541546
pad = Size.from_any(pad, fraction_ref=self._xref)
@@ -574,12 +579,17 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
574579
If False, the new axes is appended at the end
575580
of the list, i.e., it became the right-most axes. If True, it is
576581
inserted at the start of the list, and becomes the left-most axes.
577-
kwargs
582+
**kwargs
578583
All extra keywords arguments are passed to the created axes.
579584
If *axes_class* is given, the new axes will be created as an
580585
instance of the given class. Otherwise, the same class of the
581586
main axes will be used.
582587
"""
588+
if pad is None:
589+
cbook.warn_deprecated(
590+
"3.2", message="In a future version, 'pad' will default to "
591+
"rcParams['figure.subplot.hspace']. Set pad=0 to keep the "
592+
"old behavior.)
583593
if pad:
584594
if not isinstance(pad, Size._Base):
585595
pad = Size.from_any(pad, fraction_ref=self._yref)

0 commit comments

Comments
 (0)
0