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 diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py index ab6d524aee4..28dd82e76f5 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 - 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. - 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 + axes : ndarray of matplotlib.axes.Axes + Array containing axes in corresponding position, as returned from + :py:func:`matplotlib.pyplot.subplots`. + 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 that should remain empty, i.e., + sometimes the rightmost grid positions in the bottom row. """ def __init__( @@ -91,26 +91,28 @@ def __init__( Parameters ---------- data : DataArray - xarray DataArray to be plotted - row, col : strings + 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. 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 + 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 + Dictionary of keyword arguments for Matplotlib subplots + (:py:func:`matplotlib.pyplot.subplots`). """ @@ -431,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) @@ -564,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 ----------