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