Default plot of DataArray using :py:mod:`matplotlib:matplotlib.pyplot`. Calls xarray plotting function based on the dimensions of the squeezed DataArray. =============== =========================== Dimensions Plotting function =============== =========================
(
darray: DataArray,
*,
row: Hashable | None = None,
col: Hashable | None = None,
col_wrap: int | Literal["auto"] | None = None,
ax: Axes | None = None,
hue: Hashable | None = None,
subplot_kws: dict[str, Any] | None = None,
**kwargs: Any,
)
| 224 | |
| 225 | # return type is Any due to the many different possibilities |
| 226 | def plot( |
| 227 | darray: DataArray, |
| 228 | *, |
| 229 | row: Hashable | None = None, |
| 230 | col: Hashable | None = None, |
| 231 | col_wrap: int | Literal["auto"] | None = None, |
| 232 | ax: Axes | None = None, |
| 233 | hue: Hashable | None = None, |
| 234 | subplot_kws: dict[str, Any] | None = None, |
| 235 | **kwargs: Any, |
| 236 | ) -> Any: |
| 237 | """ |
| 238 | Default plot of DataArray using :py:mod:`matplotlib:matplotlib.pyplot`. |
| 239 | |
| 240 | Calls xarray plotting function based on the dimensions of |
| 241 | the squeezed DataArray. |
| 242 | |
| 243 | =============== =========================== |
| 244 | Dimensions Plotting function |
| 245 | =============== =========================== |
| 246 | 1 :py:func:`xarray.plot.line` |
| 247 | 2 :py:func:`xarray.plot.pcolormesh` |
| 248 | Anything else :py:func:`xarray.plot.hist` |
| 249 | =============== =========================== |
| 250 | |
| 251 | Parameters |
| 252 | ---------- |
| 253 | darray : DataArray |
| 254 | row : Hashable or None, optional |
| 255 | If passed, make row faceted plots on this dimension name. |
| 256 | col : Hashable or None, optional |
| 257 | If passed, make column faceted plots on this dimension name. |
| 258 | col_wrap : int, None or "auto", optional |
| 259 | "Wrap" the grid for the column variable after this number of columns, |
| 260 | adding rows if ``col_wrap`` is less than the number of facets. |
| 261 | If "auto" align the grid to the figsize or keep it as square as possible. |
| 262 | ax : matplotlib axes object, optional |
| 263 | Axes on which to plot. By default, use the current axes. |
| 264 | Mutually exclusive with ``size``, ``figsize`` and facets. |
| 265 | hue : Hashable or None, optional |
| 266 | If passed, make faceted line plots with hue on this dimension name. |
| 267 | subplot_kws : dict, optional |
| 268 | Dictionary of keyword arguments for Matplotlib subplots |
| 269 | (see :py:meth:`matplotlib:matplotlib.figure.Figure.add_subplot`). |
| 270 | **kwargs : optional |
| 271 | Additional keyword arguments for Matplotlib. |
| 272 | |
| 273 | See Also |
| 274 | -------- |
| 275 | xarray.DataArray.squeeze |
| 276 | """ |
| 277 | darray = darray.squeeze( |
| 278 | d for d, s in darray.sizes.items() if s == 1 and d not in (row, col, hue) |
| 279 | ).compute() |
| 280 | |
| 281 | plot_dims = set(darray.dims) |
| 282 | plot_dims.discard(row) |
| 283 | plot_dims.discard(col) |