Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4bafdfc

Browse files
committed
docstring: clarify usage of Figure.add_axes
1 parent 0679e93 commit 4bafdfc

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

lib/matplotlib/figure.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -633,27 +633,28 @@ def fixlist(args):
633633
@docstring.dedent_interpd
634634
def add_axes(self, *args, **kwargs):
635635
"""
636-
Add an a axes with axes rect [*left*, *bottom*, *width*,
636+
Add an axes at position *rect* [*left*, *bottom*, *width*,
637637
*height*] where all quantities are in fractions of figure
638638
width and height. kwargs are legal
639639
:class:`~matplotlib.axes.Axes` kwargs plus *projection* which
640640
sets the projection type of the axes. (For backward
641641
compatibility, ``polar=True`` may also be provided, which is
642642
equivalent to ``projection='polar'``). Valid values for
643-
*projection* are: %(projection_names)s. Some of these projections support
644-
additional kwargs, which may be provided to :meth:`add_axes`::
643+
*projection* are: %(projection_names)s. Some of these
644+
projections support additional kwargs, which may be provided
645+
to :meth:`add_axes`. Typical usage::
645646
646647
rect = l,b,w,h
647648
fig.add_axes(rect)
648649
fig.add_axes(rect, frameon=False, axisbg='g')
649650
fig.add_axes(rect, polar=True)
650651
fig.add_axes(rect, projection='polar')
651-
fig.add_axes(ax) # add an Axes instance
652+
fig.add_axes(ax)
652653
653654
If the figure already has an axes with the same parameters,
654655
then it will simply make that axes current and return it. If
655-
you do not want this behavior, eg. you want to force the
656-
creation of a new axes, you must use a unique set of args and
656+
you do not want this behavior, e.g. you want to force the
657+
creation of a new Axes, you must use a unique set of args and
657658
kwargs. The axes :attr:`~matplotlib.axes.Axes.label`
658659
attribute has been exposed for this purpose. Eg., if you want
659660
two axes that are otherwise identical to be added to the
@@ -662,9 +663,18 @@ def add_axes(self, *args, **kwargs):
662663
fig.add_axes(rect, label='axes1')
663664
fig.add_axes(rect, label='axes2')
664665
665-
The :class:`~matplotlib.axes.Axes` instance will be returned.
666+
In rare circumstances, add_axes may be called with a single
667+
argument, an Axes instance already created in the present
668+
figure but not in the figure's list of axes. For example,
669+
if an axes has been removed with :meth:`delaxes`, it can
670+
be restored with::
666671
667-
The following kwargs are supported:
672+
fig.add_axes(ax)
673+
674+
In all cases, the :class:`~matplotlib.axes.Axes` instance
675+
will be returned.
676+
677+
In addition to *projection*, the following kwargs are supported:
668678
669679
%(Axes)s
670680
"""
@@ -1321,7 +1331,7 @@ def tight_layout(self, renderer=None, pad=1.2, h_pad=None, w_pad=None):
13211331
nrows_list = []
13221332
ncols_list = []
13231333
ax_bbox_list = []
1324-
1334+
13251335
subplot_dict = {} # for axes_grid1, multiple axes can share
13261336
# same subplot_interface. Thus we need to
13271337
# join them together.
@@ -1348,7 +1358,7 @@ def tight_layout(self, renderer=None, pad=1.2, h_pad=None, w_pad=None):
13481358
subplotspec_list.append(subplotspec)
13491359
subplot_list.append(subplots)
13501360
ax_bbox_list.append(subplotspec.get_position(self))
1351-
1361+
13521362
subplots.append(ax)
13531363

13541364
max_nrows = max(nrows_list)

0 commit comments

Comments
 (0)