Skip to content

Convert get_ticklabels/add_axes/add_subplot to numpydoc #8900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3011,9 +3011,9 @@ def get_xticklabels(self, minor=False, which=None):

Parameters
----------
minor : bool
minor : bool, optional
If True return the minor ticklabels,
else return the major ticklabels
else return the major ticklabels.

which : None, ('minor', 'major', 'both')
Overrides `minor`.
Expand All @@ -3038,6 +3038,19 @@ def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs):
labels : list of str
list of string labels

fontdict : dict, optional
A dictionary controlling the appearance of the ticklabels,
the default `fontdict` is:

{'fontsize': rcParams['axes.titlesize'],
'fontweight' : rcParams['axes.titleweight'],
'verticalalignment': 'baseline',
'horizontalalignment': loc}

minor : bool, optional
If True select the minor ticklabels,
else select the minor ticklabels

Returns
-------
A list of `~matplotlib.text.Text` instances
Expand Down Expand Up @@ -3335,6 +3348,19 @@ def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs):
labels : list of str
list of string labels

fontdict : dict, optional
A dictionary controlling the appearance of the ticklabels,
the default `fontdict` is::

{'fontsize': rcParams['axes.titlesize'],
'fontweight' : rcParams['axes.titleweight'],
'verticalalignment': 'baseline',
'horizontalalignment': loc}

minor : bool, optional
If True select the minor ticklabels,
else select the minor ticklabels

Returns
-------
A list of `~matplotlib.text.Text` instances.
Expand Down
95 changes: 59 additions & 36 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,20 +860,35 @@ def fixlist(args):
key = fixlist(args), fixitems(six.iteritems(kwargs))
return key

@docstring.dedent_interpd
def add_axes(self, *args, **kwargs):
"""
Add an axes at position *rect* [*left*, *bottom*, *width*,
*height*] where all quantities are in fractions of figure
width and height. kwargs are legal
:class:`~matplotlib.axes.Axes` kwargs plus *projection* which
sets the projection type of the axes. (For backward
compatibility, ``polar=True`` may also be provided, which is
equivalent to ``projection='polar'``). Valid values for
*projection* are: %(projection_names)s. Some of these
projections support additional kwargs, which may be provided
to :meth:`add_axes`. Typical usage::
width and height.

Parameters
----------
rect : sequence of float
A 4-length sequence of [left, bottom, width, height] quantities.

projection :
['aitoff' | 'hammer' | 'lambert' | 'mollweide' | \
'polar' | 'rectilinear'], optional
The projection type of the axes.

polar : boolean, optional
If True, equivalent to projection='polar'.

This method also takes the keyword arguments for
:class:`~matplotlib.axes.Axes`.

Returns
------
axes : Axes
The added axes.

Examples
--------
rect = l,b,w,h
fig.add_axes(rect)
fig.add_axes(rect, frameon=False, facecolor='g')
Expand Down Expand Up @@ -903,10 +918,6 @@ def add_axes(self, *args, **kwargs):

In all cases, the :class:`~matplotlib.axes.Axes` instance
will be returned.

In addition to *projection*, the following kwargs are supported:

%(Axes)s
"""
if not len(args):
return
Expand Down Expand Up @@ -949,11 +960,41 @@ def add_axes(self, *args, **kwargs):
a.stale_callback = _stale_figure_callback
return a

@docstring.dedent_interpd
def add_subplot(self, *args, **kwargs):
"""
Add a subplot. Examples::
Add a subplot.

Parameters
----------
*args
Either a 3-digit integer or three separate integers
describing the position of the subplot. If the three
integers are I, J, and K, the subplot is the Ith plot on a
grid with J rows and K columns.

projection : ['aitoff' | 'hammer' | 'lambert' | \
'mollweide', 'polar' | 'rectilinear'], optional
The projection type of the axes.

polar : boolean, optional
If True, equivalent to projection='polar'.

This method also takes the keyword arguments for
:class:`~matplotlib.axes.Axes`.

Returns
-------
axes : Axes
The axes of the subplot.

Notes
-----
If the figure already has a subplot with key (*args*,
*kwargs*) then it will simply make that subplot current and
return it.

Examples
--------
fig.add_subplot(111)

# equivalent but more general
Expand All @@ -968,27 +1009,9 @@ def add_subplot(self, *args, **kwargs):
# add Subplot instance sub
fig.add_subplot(sub)

*kwargs* are legal :class:`~matplotlib.axes.Axes` kwargs plus
*projection*, which chooses a projection type for the axes.
(For backward compatibility, *polar=True* may also be
provided, which is equivalent to *projection='polar'*). Valid
values for *projection* are: %(projection_names)s. Some of
these projections
support additional *kwargs*, which may be provided to
:meth:`add_axes`.

The :class:`~matplotlib.axes.Axes` instance will be returned.

If the figure already has a subplot with key (*args*,
*kwargs*) then it will simply make that subplot current and
return it.

.. seealso:: :meth:`~matplotlib.pyplot.subplot` for an
explanation of the args.

The following kwargs are supported:

%(Axes)s
See Also
--------
matplotlib.pyplot.subplot : for an explanation of the args.
"""
if not len(args):
return
Expand Down