From a3057762b8446cd06293d209e256e7559c2601fb Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 1 Nov 2017 01:13:37 -0700 Subject: [PATCH 1/2] Reoder Axes API docs. The previous order was a bit of a mess. I went for set_xfoo, get_xfoo, set_yfoo, get_yfoo although set_xfoo, set_yfoo, get_xfoo, get_yfoo would probably have worked equally well. --- doc/api/axes_api.rst | 74 ++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/doc/api/axes_api.rst b/doc/api/axes_api.rst index 8bea5b8aaf0b..8a764092fd63 100644 --- a/doc/api/axes_api.rst +++ b/doc/api/axes_api.rst @@ -239,16 +239,16 @@ Property cycle Axis / limits ============= +.. For families of methods of the form {get,set}_{x,y}foo, try to list them in + the order set_xfoo, get_xfoo, set_yfoo, get_yfoo + .. autosummary:: :toctree: _as_gen :template: autosummary.rst :nosignatures: - - Axes.get_yaxis Axes.get_xaxis - - + Axes.get_yaxis Axis Limits and direction ------------------------- @@ -259,23 +259,22 @@ Axis Limits and direction :nosignatures: Axes.invert_xaxis - Axes.invert_yaxis Axes.xaxis_inverted + Axes.invert_yaxis Axes.yaxis_inverted Axes.set_xlim + Axes.get_xlim Axes.set_ylim Axes.get_ylim - Axes.get_xlim Axes.update_datalim Axes.update_datalim_bounds - Axes.update_datalim_numerix - Axes.set_ybound Axes.set_xbound - Axes.get_ybound Axes.get_xbound + Axes.set_ybound + Axes.get_ybound Axis Labels, title, and legend ------------------------------ @@ -285,11 +284,10 @@ Axis Labels, title, and legend :template: autosummary.rst :nosignatures: - Axes.get_xlabel - Axes.get_ylabel - Axes.set_xlabel + Axes.get_xlabel Axes.set_ylabel + Axes.get_ylabel Axes.set_title Axes.get_title @@ -297,7 +295,6 @@ Axis Labels, title, and legend Axes.get_legend Axes.get_legend_handles_labels - Axis scales ----------- @@ -308,11 +305,8 @@ Axis scales Axes.set_xscale Axes.get_xscale - - Axes.get_yscale Axes.set_yscale - - + Axes.get_yscale Autoscaling and margins ----------------------- @@ -333,15 +327,14 @@ Autoscaling and margins Axes.autoscale Axes.autoscale_view - Axes.get_autoscale_on Axes.set_autoscale_on + Axes.get_autoscale_on - Axes.get_autoscalex_on Axes.set_autoscalex_on + Axes.get_autoscalex_on - Axes.get_autoscaley_on Axes.set_autoscaley_on - + Axes.get_autoscaley_on Aspect ratio ------------ @@ -352,48 +345,48 @@ Aspect ratio :nosignatures: Axes.apply_aspect - Axes.get_aspect Axes.set_aspect + Axes.get_aspect - Axes.get_adjustable Axes.set_adjustable - + Axes.get_adjustable Ticks and tick labels --------------------- - .. autosummary:: :toctree: _as_gen :template: autosummary.rst :nosignatures: - Axes.xaxis_date - Axes.yaxis_date + Axes.set_xticks + Axes.get_xticks + Axes.set_xticklabels + Axes.get_xticklabels Axes.get_xmajorticklabels Axes.get_xminorticklabels - Axes.get_xticklabels + + Axes.get_xgridlines Axes.get_xticklines - Axes.get_xticks - Axes.get_ymajorticklabels - Axes.get_yminorticklabels - Axes.get_yticklabels - Axes.get_yticklines - Axes.get_yticks + Axes.xaxis_date - Axes.minorticks_off - Axes.minorticks_on + Axes.set_yticks + Axes.get_yticks - Axes.set_xticklabels - Axes.set_xticks Axes.set_yticklabels - Axes.set_yticks + Axes.get_yticklabels + Axes.get_ymajorticklabels + Axes.get_yminorticklabels - Axes.get_xgridlines Axes.get_ygridlines + Axes.get_yticklines + + Axes.yaxis_date + Axes.minorticks_off + Axes.minorticks_on Axes.ticklabel_format Axes.tick_params @@ -401,7 +394,6 @@ Ticks and tick labels Axes.locator_params - Units ===== From e4178d8826322f62ce5a9781abd52dd5597875df Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 1 Nov 2017 01:26:44 -0700 Subject: [PATCH 2/2] Improve a few docstrings. --- lib/matplotlib/axes/_base.py | 59 ++++++++++++------------------------ 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index a67f6b2bd866..e122658c2cd8 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -1612,9 +1612,7 @@ def axis(self, *v, **kwargs): return v def get_legend(self): - """ - Return the legend.Legend instance, or None if no legend is defined - """ + """Return the `Legend` instance, or None if no legend is defined.""" return self.legend_ def get_images(self): @@ -1626,30 +1624,30 @@ def get_lines(self): return cbook.silent_list('Line2D', self.lines) def get_xaxis(self): - """Return the XAxis instance""" + """Return the XAxis instance.""" return self.xaxis def get_xgridlines(self): - """Get the x grid lines as a list of Line2D instances""" + """Get the x grid lines as a list of `Line2D` instances.""" return cbook.silent_list('Line2D xgridline', self.xaxis.get_gridlines()) def get_xticklines(self): - """Get the xtick lines as a list of Line2D instances""" - return cbook.silent_list('Text xtickline', + """Get the x tick lines as a list of `Line2D` instances.""" + return cbook.silent_list('Line2D xtickline', self.xaxis.get_ticklines()) def get_yaxis(self): - """Return the YAxis instance""" + """Return the YAxis instance.""" return self.yaxis def get_ygridlines(self): - """Get the y grid lines as a list of Line2D instances""" + """Get the y grid lines as a list of `Line2D` instances.""" return cbook.silent_list('Line2D ygridline', self.yaxis.get_gridlines()) def get_yticklines(self): - """Get the ytick lines as a list of Line2D instances""" + """Get the y tick lines as a list of `Line2D` instances.""" return cbook.silent_list('Line2D ytickline', self.yaxis.get_ticklines()) @@ -2746,27 +2744,16 @@ def set_axis_bgcolor(self, color): # data limits, ticks, tick labels, and formatting def invert_xaxis(self): - "Invert the x-axis." - left, right = self.get_xlim() - self.set_xlim(right, left, auto=None) + """Invert the x-axis.""" + self.set_xlim(self.get_xlim()[::-1], auto=None) def xaxis_inverted(self): - """Returns *True* if the x-axis is inverted.""" + """Return whether the x-axis is inverted.""" left, right = self.get_xlim() return right < left def get_xbound(self): - """Returns the x-axis numerical bounds - - This always returns:: - - lowerBound < upperBound - - Returns - ------- - lowerBound, upperBound : float - - """ + """Return the lower and upper x-axis bounds, in increasing order.""" left, right = self.get_xlim() if left < right: return left, right @@ -3002,7 +2989,7 @@ def set_xticks(self, ticks, minor=False): def get_xmajorticklabels(self): """ - Get the xtick major labels + Get the major x tick labels. Returns ------- @@ -3014,7 +3001,7 @@ def get_xmajorticklabels(self): def get_xminorticklabels(self): """ - Get the x minor tick labels + Get the minor x tick labels. Returns ------- @@ -3086,22 +3073,16 @@ def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs): return ret def invert_yaxis(self): - """ - Invert the y-axis. - """ - bottom, top = self.get_ylim() - self.set_ylim(top, bottom, auto=None) + """Invert the y-axis.""" + self.set_ylim(self.get_ylim()[::-1], auto=None) def yaxis_inverted(self): - """Returns *True* if the y-axis is inverted.""" + """Return whether the y-axis is inverted.""" bottom, top = self.get_ylim() return top < bottom def get_ybound(self): - """ - Return y-axis numerical bounds in the form of - ``lowerBound < upperBound`` - """ + """Return the lower and upper y-axis bounds, in increasing order.""" bottom, top = self.get_ylim() if bottom < top: return bottom, top @@ -3316,7 +3297,7 @@ def set_yticks(self, ticks, minor=False): def get_ymajorticklabels(self): """ - Get the major y tick labels + Get the major y tick labels. Returns ------- @@ -3328,7 +3309,7 @@ def get_ymajorticklabels(self): def get_yminorticklabels(self): """ - Get the minor y tick labels + Get the minor y tick labels. Returns -------