Labeled data enables expressive computations. These same
labels can also be used to easily create informative plots.

xarray’s plotting capabilities are centered around
xarray.DataArray objects.
To plot xarray.Dataset objects
simply access the relevant DataArrays, ie dset['var1'].
Here we focus mostly on arrays 2d or larger. If your data fits
nicely into a pandas DataFrame then you’re better off using one of the more
developed tools there.

xarray plotting functionality is a thin wrapper around the popular
matplotlib library.
Matplotlib syntax and function names were copied as much as possible, which
makes for an easy transition between the two.
Matplotlib must be installed before xarray can plot.

For more extensive plotting applications consider the following projects:

xarray uses the coordinate name along with metadata attrs.long_name, attrs.standard_name, DataArray.name and attrs.units (if available) to label the axes. The names long_name, standard_name and units are copied from the CF-conventions spec. When choosing names, the order of precedence is long_name, standard_name and finally DataArray.name. The y-axis label in the above plot was constructed from the long_name and units attributes of air1d.

Additional arguments are passed directly to the matplotlib function which
does the work.
For example, xarray.plot.line() calls
matplotlib.pyplot.plot passing in the index and the array values as x and y, respectively.
So to make a line plot with blue triangles a matplotlib format string
can be used:

In [13]: air1d[:200].plot.line('b-^')Out[13]: [<matplotlib.lines.Line2D at 0x7f1da02f93c8>]

Note

Not all xarray plotting methods support passing positional arguments
to the wrapped matplotlib functions, but they do all
support keyword arguments.

Keyword arguments work the same way, and are more explicit.

In [14]: air1d[:200].plot.line(color='purple',marker='o')Out[14]: [<matplotlib.lines.Line2D at 0x7f1da0431be0>]

To add the plot to an existing axis pass in the axis as a keyword argument
ax. This works for all xarray plotting methods.
In this example axes is an array consisting of the left and right
axes created by plt.subplots.