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