MCPcopy
hub / github.com/matplotlib/matplotlib / add_subplot

Method add_subplot

lib/matplotlib/figure.py:652–777  ·  view source on GitHub ↗

Add an `~.axes.Axes` to the figure as part of a subplot arrangement. Call signatures:: add_subplot(nrows, ncols, index, **kwargs) add_subplot(pos, **kwargs) add_subplot(ax) add_subplot() Parameters ---------- *ar

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

650
651 @_docstring.interpd
652 def add_subplot(self, *args, **kwargs):
653 """
654 Add an `~.axes.Axes` to the figure as part of a subplot arrangement.
655
656 Call signatures::
657
658 add_subplot(nrows, ncols, index, **kwargs)
659 add_subplot(pos, **kwargs)
660 add_subplot(ax)
661 add_subplot()
662
663 Parameters
664 ----------
665 *args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1)
666 The position of the subplot described by one of
667
668 - Three integers (*nrows*, *ncols*, *index*). The subplot will
669 take the *index* position on a grid with *nrows* rows and
670 *ncols* columns. *index* starts at 1 in the upper left corner
671 and increases to the right. *index* can also be a two-tuple
672 specifying the (*first*, *last*) indices (1-based, and including
673 *last*) of the subplot, e.g., ``fig.add_subplot(3, 1, (1, 2))``
674 makes a subplot that spans the upper 2/3 of the figure.
675 - A 3-digit integer. The digits are interpreted as if given
676 separately as three single-digit integers, i.e.
677 ``fig.add_subplot(235)`` is the same as
678 ``fig.add_subplot(2, 3, 5)``. Note that this can only be used
679 if there are no more than 9 subplots.
680 - A `.SubplotSpec`.
681
682 In rare circumstances, `.add_subplot` may be called with a single
683 argument, a subplot Axes instance already created in the
684 present figure but not in the figure's list of Axes.
685
686 projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
687'polar', 'rectilinear', str}, optional
688 The projection type of the subplot (`~.axes.Axes`). *str* is the
689 name of a custom projection, see `~matplotlib.projections`. The
690 default None results in a 'rectilinear' projection.
691
692 polar : bool, default: False
693 If True, equivalent to projection='polar'.
694
695 axes_class : subclass type of `~.axes.Axes`, optional
696 The `.axes.Axes` subclass that is instantiated. This parameter
697 is incompatible with *projection* and *polar*. See
698 :ref:`axisartist_users-guide-index` for examples.
699
700 sharex, sharey : `~matplotlib.axes.Axes`, optional
701 Share the x or y `~matplotlib.axis` with sharex and/or sharey.
702 The axis will have the same limits, ticks, and scale as the axis
703 of the shared Axes.
704
705 label : str
706 A label for the returned Axes.
707
708 Returns
709 -------

Callers 15

gcaMethod · 0.95
_do_layoutMethod · 0.95
__call__Method · 0.80
test_grid_offFunction · 0.80
test_axes3d_reprFunction · 0.80
test_bar3dFunction · 0.80
test_bar3d_colorsFunction · 0.80
test_bar3d_notshadedFunction · 0.80
test_bar3d_lightsourceFunction · 0.80
test_contour3dFunction · 0.80
test_contour3d_extend3dFunction · 0.80

Calls 4

_add_axes_internalMethod · 0.95
get_subplotspecMethod · 0.45
get_figureMethod · 0.45

Tested by 15

test_grid_offFunction · 0.64
test_axes3d_reprFunction · 0.64
test_bar3dFunction · 0.64
test_bar3d_colorsFunction · 0.64
test_bar3d_notshadedFunction · 0.64
test_bar3d_lightsourceFunction · 0.64
test_contour3dFunction · 0.64
test_contour3d_extend3dFunction · 0.64
test_contourf3dFunction · 0.64
test_contourf3d_fillFunction · 0.64
test_contourf3d_extendFunction · 0.64