From ccb39f886268e6306fc156fd71cd66a2ac18dc77 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 12 May 2021 11:23:08 -0400 Subject: [PATCH 1/7] Add the `add_quiverkey` method to docs --- doc/api.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api.rst b/doc/api.rst index 7c01a8af0f1..1bd4eee9b12 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -846,6 +846,7 @@ Faceting plot.FacetGrid plot.FacetGrid.add_colorbar plot.FacetGrid.add_legend + plot.FacetGrid.add_quiverkey plot.FacetGrid.map plot.FacetGrid.map_dataarray plot.FacetGrid.map_dataarray_line From e91d50afbe9a479985393e8addc7fce27c52dd91 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 12 May 2021 11:33:39 -0400 Subject: [PATCH 2/7] Improve class docstring --- xarray/plot/facetgrid.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index ab6d524aee4..ecec049aa80 100644 --- a/xarray/plot/facetgrid.py +++ b/xarray/plot/facetgrid.py @@ -35,13 +35,13 @@ def _nicetitle(coord, value, maxchar, template): class FacetGrid: """ - Initialize the matplotlib figure and FacetGrid object. + Initialize the Matplotlib figure and FacetGrid object. The :class:`FacetGrid` is an object that links a xarray DataArray to - a matplotlib figure with a particular structure. + a Matplotlib figure with a particular structure. In particular, :class:`FacetGrid` is used to draw plots with multiple - Axes where each Axes shows the same relationship conditioned on + axes, where each axes shows the same relationship conditioned on different levels of some dimension. It's possible to condition on up to two variables by assigning variables to the rows and columns of the grid. @@ -59,19 +59,19 @@ class FacetGrid: Attributes ---------- - axes : numpy object array - Contains axes in corresponding position, as returned from - plt.subplots + axes : ndarray of matplotlib.axes.Axes + Array containing axes in corresponding position, as returned from + :func:`matplotlib.pyplot.subplots`. col_labels : list - list of :class:`matplotlib.text.Text` instances corresponding to column titles. + List of :class:`matplotlib.text.Text` instances corresponding to column titles. row_labels : list - list of :class:`matplotlib.text.Text` instances corresponding to row titles. - fig : matplotlib.Figure - The figure containing all the axes - name_dicts : numpy object array - Contains dictionaries mapping coordinate names to values. None is - used as a sentinel value for axes which should remain empty, ie. - sometimes the bottom right grid + List of :class:`matplotlib.text.Text` instances corresponding to row titles. + fig : matplotlib.figure.Figure + The figure containing all the axes. + name_dicts : ndarray of dict + Array containing dictionaries mapping coordinate names to values. ``None`` is + used as a sentinel value for axes which should remain empty, that is, + sometimes the rightmost grid positions in the bottom row. """ def __init__( From 0b644f3c36f35668e1d226dcba8ffe4ca4f33665 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 12 May 2021 11:38:35 -0400 Subject: [PATCH 3/7] FacetGrid init just a bit --- xarray/plot/facetgrid.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index ecec049aa80..5e57dd840af 100644 --- a/xarray/plot/facetgrid.py +++ b/xarray/plot/facetgrid.py @@ -98,9 +98,9 @@ def __init__( col_wrap : int, optional "Wrap" the column variable at this width, so that the column facets sharex : bool, optional - If true, the facets will share x axes + If true, the facets will share *x* axes sharey : bool, optional - If true, the facets will share y axes + If true, the facets will share *y* axes figsize : tuple, optional A tuple (width, height) of the figure in inches. If set, overrides ``size`` and ``aspect``. @@ -110,7 +110,8 @@ def __init__( size : scalar, optional Height (in inches) of each facet. See also: ``aspect`` subplot_kws : dict, optional - Dictionary of keyword arguments for matplotlib subplots + Dictionary of keyword arguments for Matplotlib subplots + (:func:`matplotlib.pyplot.subplots`). """ From 19717c1a927744875b19ff1308cfa494f3ca69b6 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 12 May 2021 11:41:51 -0400 Subject: [PATCH 4/7] More tweaks --- xarray/plot/facetgrid.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index 5e57dd840af..ab8c6f6e45c 100644 --- a/xarray/plot/facetgrid.py +++ b/xarray/plot/facetgrid.py @@ -62,15 +62,15 @@ class FacetGrid: axes : ndarray of matplotlib.axes.Axes Array containing axes in corresponding position, as returned from :func:`matplotlib.pyplot.subplots`. - col_labels : list - List of :class:`matplotlib.text.Text` instances corresponding to column titles. - row_labels : list - List of :class:`matplotlib.text.Text` instances corresponding to row titles. + col_labels : list of matplotlib.text.Text + Column titles. + row_labels : list of matplotlib.text.Text + Row titles. fig : matplotlib.figure.Figure The figure containing all the axes. name_dicts : ndarray of dict Array containing dictionaries mapping coordinate names to values. ``None`` is - used as a sentinel value for axes which should remain empty, that is, + used as a sentinel value for axes that should remain empty, i.e., sometimes the rightmost grid positions in the bottom row. """ @@ -92,7 +92,7 @@ def __init__( ---------- data : DataArray xarray DataArray to be plotted - row, col : strings + row, col : str Dimesion names that define subsets of the data, which will be drawn on separate facets in the grid. col_wrap : int, optional From f6ae3317ef75691a6a9ef8f618d0f35a9fa667b1 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 12 May 2021 11:43:55 -0400 Subject: [PATCH 5/7] reword not sure what `col_wrap` descrip was trying to say --- xarray/plot/facetgrid.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index ab8c6f6e45c..a03c2bcdad0 100644 --- a/xarray/plot/facetgrid.py +++ b/xarray/plot/facetgrid.py @@ -96,7 +96,8 @@ def __init__( Dimesion names that define subsets of the data, which will be drawn on separate facets in the grid. col_wrap : int, optional - "Wrap" the column variable at this width, so that the column facets + "Wrap" the grid the for the column variable after this number of columns, + adding rows if ``col_wrap`` is less than the number of facets. sharex : bool, optional If true, the facets will share *x* axes sharey : bool, optional From 68b24079daf888bd8d9c44115b7d447d53ae71c1 Mon Sep 17 00:00:00 2001 From: Zachary Moon Date: Wed, 12 May 2021 20:25:22 -0400 Subject: [PATCH 6/7] Use `:py:func:` instead of `:func:` Co-authored-by: keewis --- xarray/plot/facetgrid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index a03c2bcdad0..253041eea65 100644 --- a/xarray/plot/facetgrid.py +++ b/xarray/plot/facetgrid.py @@ -112,7 +112,7 @@ def __init__( Height (in inches) of each facet. See also: ``aspect`` subplot_kws : dict, optional Dictionary of keyword arguments for Matplotlib subplots - (:func:`matplotlib.pyplot.subplots`). + (:py:func:`matplotlib.pyplot.subplots`). """ From 067065c26860aea0584add8201b2b3063b163b12 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 12 May 2021 22:04:31 -0400 Subject: [PATCH 7/7] Add periods; use `:py:func:` for other subplots [skip-ci] --- xarray/plot/facetgrid.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index 253041eea65..28dd82e76f5 100644 --- a/xarray/plot/facetgrid.py +++ b/xarray/plot/facetgrid.py @@ -61,7 +61,7 @@ class FacetGrid: ---------- axes : ndarray of matplotlib.axes.Axes Array containing axes in corresponding position, as returned from - :func:`matplotlib.pyplot.subplots`. + :py:func:`matplotlib.pyplot.subplots`. col_labels : list of matplotlib.text.Text Column titles. row_labels : list of matplotlib.text.Text @@ -91,7 +91,7 @@ def __init__( Parameters ---------- data : DataArray - xarray DataArray to be plotted + xarray DataArray to be plotted. row, col : str Dimesion names that define subsets of the data, which will be drawn on separate facets in the grid. @@ -99,17 +99,17 @@ def __init__( "Wrap" the grid the for the column variable after this number of columns, adding rows if ``col_wrap`` is less than the number of facets. sharex : bool, optional - If true, the facets will share *x* axes + If true, the facets will share *x* axes. sharey : bool, optional - If true, the facets will share *y* axes + If true, the facets will share *y* axes. figsize : tuple, optional A tuple (width, height) of the figure in inches. If set, overrides ``size`` and ``aspect``. aspect : scalar, optional Aspect ratio of each facet, so that ``aspect * size`` gives the - width of each facet in inches + width of each facet in inches. size : scalar, optional - Height (in inches) of each facet. See also: ``aspect`` + Height (in inches) of each facet. See also: ``aspect``. subplot_kws : dict, optional Dictionary of keyword arguments for Matplotlib subplots (:py:func:`matplotlib.pyplot.subplots`). @@ -433,7 +433,7 @@ def add_legend(self, **kwargs): self._adjust_fig_for_guide(self.figlegend) def add_colorbar(self, **kwargs): - """Draw a colorbar""" + """Draw a colorbar.""" kwargs = kwargs.copy() if self._cmap_extend is not None: kwargs.setdefault("extend", self._cmap_extend) @@ -566,7 +566,7 @@ def set_titles(self, template="{coord} = {value}", maxchar=30, size=None, **kwar def set_ticks(self, max_xticks=_NTICKS, max_yticks=_NTICKS, fontsize=_FONTSIZE): """ - Set and control tick behavior + Set and control tick behavior. Parameters ----------