@@ -441,26 +441,11 @@ def _get_new_axes(self, *, axes_class=None, **kwargs):
441
441
442
442
def new_horizontal (self , size , pad = None , pack_start = False , ** kwargs ):
443
443
"""
444
- Add a new axes on the right (or left) side of the main axes .
444
+ Helper method for ``append_axes(" left")`` and ``append_axes("right")`` .
445
445
446
- Parameters
447
- ----------
448
- size : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
449
- The axes width. float or str arguments are interpreted as
450
- ``axes_size.from_any(size, AxesX(<main_axes>))``.
451
- pad : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
452
- Padding between the axes. float or str arguments are interpreted
453
- as ``axes_size.from_any(size, AxesX(<main_axes>))``. Defaults to
454
- :rc:`figure.subplot.wspace` times the main axes width.
455
- pack_start : bool
456
- If False, the new axes is appended at the end
457
- of the list, i.e., it became the right-most axes. If True, it is
458
- inserted at the start of the list, and becomes the left-most axes.
459
- **kwargs
460
- All extra keywords arguments are passed to the created axes.
461
- If *axes_class* is given, the new axes will be created as an
462
- instance of the given class. Otherwise, the same class of the
463
- main axes will be used.
446
+ See the documentation of `append_axes` for more details.
447
+
448
+ :meta private:
464
449
"""
465
450
if pad is None :
466
451
pad = mpl .rcParams ["figure.subplot.wspace" ] * self ._xref
@@ -488,26 +473,11 @@ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
488
473
489
474
def new_vertical (self , size , pad = None , pack_start = False , ** kwargs ):
490
475
"""
491
- Add a new axes on the top (or bottom) side of the main axes .
476
+ Helper method for ``append_axes(" top")`` and ``append_axes(" bottom")`` .
492
477
493
- Parameters
494
- ----------
495
- size : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
496
- The axes height. float or str arguments are interpreted as
497
- ``axes_size.from_any(size, AxesY(<main_axes>))``.
498
- pad : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
499
- Padding between the axes. float or str arguments are interpreted
500
- as ``axes_size.from_any(size, AxesY(<main_axes>))``. Defaults to
501
- :rc:`figure.subplot.hspace` times the main axes height.
502
- pack_start : bool
503
- If False, the new axes is appended at the end
504
- of the list, i.e., it became the right-most axes. If True, it is
505
- inserted at the start of the list, and becomes the left-most axes.
506
- **kwargs
507
- All extra keywords arguments are passed to the created axes.
508
- If *axes_class* is given, the new axes will be created as an
509
- instance of the given class. Otherwise, the same class of the
510
- main axes will be used.
478
+ See the documentation of `append_axes` for more details.
479
+
480
+ :meta private:
511
481
"""
512
482
if pad is None :
513
483
pad = mpl .rcParams ["figure.subplot.hspace" ] * self ._yref
@@ -528,31 +498,47 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
528
498
else :
529
499
self ._vertical .append (size )
530
500
locator = self .new_locator (
531
- nx = self ._xrefindex , ny = len (self ._vertical )- 1 )
501
+ nx = self ._xrefindex , ny = len (self ._vertical ) - 1 )
532
502
ax = self ._get_new_axes (** kwargs )
533
503
ax .set_axes_locator (locator )
534
504
return ax
535
505
536
506
@_api .delete_parameter ("3.5" , "add_to_figure" , alternative = "ax.remove()" )
537
- def append_axes (self , position , size , pad = None , add_to_figure = True ,
538
- ** kwargs ):
507
+ def append_axes (self , position , size , pad = None , add_to_figure = True , * ,
508
+ axes_class = None , ** kwargs ):
539
509
"""
540
- Create an axes at the given *position* with the same height
541
- (or width) of the main axes.
542
-
543
- *position*
544
- ["left"|"right"|"bottom"|"top"]
510
+ Add a new axes on a given side of the main axes.
545
511
546
- *size* and *pad* should be axes_grid.axes_size compatible.
512
+ Parameters
513
+ ----------
514
+ position : {"left", "right", "bottom", "top"}
515
+ Where the new axes is positioned relative to the main axes.
516
+ size : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
517
+ The axes width or height. float or str arguments are interpreted
518
+ as ``axes_size.from_any(size, AxesX(<main_axes>))`` for left or
519
+ right axes, and likewise with ``AxesY`` for bottom or top axes.
520
+ pad : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
521
+ Padding between the axes. float or str arguments are interpreted
522
+ as for *size*. Defaults to :rc:`figure.subplot.wspace` times the
523
+ main axes width (left or right axes) or :rc:`figure.subplot.hspace`
524
+ times the main axes height (bottom or top axes).
525
+ axes_class : subclass type of `~.axes.Axes`, optional
526
+ The type of the new axes. Defaults to the type of the main axes.
527
+ **kwargs
528
+ All extra keywords arguments are passed to the created axes.
547
529
"""
548
530
if position == "left" :
549
- ax = self .new_horizontal (size , pad , pack_start = True , ** kwargs )
531
+ ax = self .new_horizontal (
532
+ size , pad , pack_start = True , axes_class = axes_class , ** kwargs )
550
533
elif position == "right" :
551
- ax = self .new_horizontal (size , pad , pack_start = False , ** kwargs )
534
+ ax = self .new_horizontal (
535
+ size , pad , pack_start = False , axes_class = axes_class , ** kwargs )
552
536
elif position == "bottom" :
553
- ax = self .new_vertical (size , pad , pack_start = True , ** kwargs )
537
+ ax = self .new_vertical (
538
+ size , pad , pack_start = True , axes_class = axes_class , ** kwargs )
554
539
elif position == "top" :
555
- ax = self .new_vertical (size , pad , pack_start = False , ** kwargs )
540
+ ax = self .new_vertical (
541
+ size , pad , pack_start = False , axes_class = axes_class , ** kwargs )
556
542
else :
557
543
_api .check_in_list (["left" , "right" , "bottom" , "top" ],
558
544
position = position )
0 commit comments