From 909557b550d17e659d0a3d074cb87434f72adf50 Mon Sep 17 00:00:00 2001 From: ruin Date: Sun, 16 Jul 2017 16:43:41 -0500 Subject: [PATCH 1/2] Convert get_ticklabels/add_axes/add_subplot to numpydoc --- lib/matplotlib/axes/_base.py | 30 +++++++++++- lib/matplotlib/figure.py | 95 ++++++++++++++++++++++-------------- 2 files changed, 87 insertions(+), 38 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index e5f189c94b62..1697e91e0862 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -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`. @@ -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 @@ -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. diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index ac1eda6716ca..edf1f812e776 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -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') @@ -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 @@ -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 @@ -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 From 74915fbbf801660faa0ad65c31f15220ae10b196 Mon Sep 17 00:00:00 2001 From: ruin Date: Mon, 17 Jul 2017 10:21:24 -0500 Subject: [PATCH 2/2] Replace smart quotes --- lib/matplotlib/figure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index edf1f812e776..3067acea87e2 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -872,8 +872,8 @@ def add_axes(self, *args, **kwargs): A 4-length sequence of [left, bottom, width, height] quantities. projection : - [‘aitoff’ | ‘hammer’ | ‘lambert’ | ‘mollweide’ | \ -‘polar’ | ‘rectilinear’], optional + ['aitoff' | 'hammer' | 'lambert' | 'mollweide' | \ +'polar' | 'rectilinear'], optional The projection type of the axes. polar : boolean, optional @@ -972,8 +972,8 @@ def add_subplot(self, *args, **kwargs): 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 + projection : ['aitoff' | 'hammer' | 'lambert' | \ +'mollweide', 'polar' | 'rectilinear'], optional The projection type of the axes. polar : boolean, optional