xarray.plot.FacetGrid¶
-
class
xarray.plot.
FacetGrid
(data, col=None, row=None, col_wrap=None, sharex=True, sharey=True, figsize=None, aspect=1, size=3, subplot_kws=None)¶ Initialize the matplotlib figure and FacetGrid object.
The
FacetGrid
is an object that links a xarray DataArray to a matplotlib figure with a particular structure.In particular,
FacetGrid
is used to draw plots with multiple 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.The general approach to plotting here is called “small multiples”, where the same kind of plot is repeated multiple times, and the specific use of small multiples to display the same relationship conditioned on one ore more other variables is often called a “trellis plot”.
The basic workflow is to initialize the
FacetGrid
object with the DataArray and the variable names that are used to structure the grid. Then plotting functions can be applied to each subset by callingFacetGrid.map_dataarray()
orFacetGrid.map()
.-
axes
¶ Contains axes in corresponding position, as returned from plt.subplots
Type: numpy object array
-
fig
¶ The figure containing all the axes
Type: matplotlib.Figure
-
name_dicts
¶ 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
Type: numpy object array
-
__init__
(data, col=None, row=None, col_wrap=None, sharex=True, sharey=True, figsize=None, aspect=1, size=3, subplot_kws=None)¶ Parameters: - data (DataArray) – xarray DataArray to be plotted
- col (row,) – 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
- sharex (bool, optional) – If true, the facets will share x axes
- sharey (bool, optional) – If true, the facets will share y axes
- figsize (tuple, optional) – A tuple (width, height) of the figure in inches.
If set, overrides
size
andaspect
. - aspect (scalar, optional) – Aspect ratio of each facet, so that
aspect * size
gives the width of each facet in inches - size (scalar, optional) – Height (in inches) of each facet. See also:
aspect
- subplot_kws (dict, optional) – Dictionary of keyword arguments for matplotlib subplots
Methods
__init__
(data[, col, row, col_wrap, sharex, …])param data: xarray DataArray to be plotted add_colorbar
(**kwargs)Draw a colorbar add_legend
(**kwargs)map
(func, *args, **kwargs)Apply a plotting function to each facet’s subset of the data. map_dataarray
(func, x, y, **kwargs)Apply a plotting function to a 2d facet’s subset of the data. map_dataarray_line
(func, x, y, hue[, …])map_dataset
(func[, x, y, hue, hue_style, …])set_axis_labels
([x_var, y_var])Set axis labels on the left column and bottom row of the grid. set_ticks
([max_xticks, max_yticks, fontsize])Set and control tick behavior set_titles
([template, maxchar, size])Draw titles either above each facet or on the grid margins. set_xlabels
([label])Label the x axis on the bottom row of the grid. set_ylabels
([label])Label the y axis on the left column of the grid. -