diff --git a/doc/plotting.rst b/doc/plotting.rst index 72248e31b1e..02ddba1e00c 100644 --- a/doc/plotting.rst +++ b/doc/plotting.rst @@ -743,12 +743,13 @@ This script will plot the air temperature on a map. air = xr.tutorial.open_dataset("air_temperature").air - ax = plt.axes(projection=ccrs.Orthographic(-80, 35)) - air.isel(time=0).plot.contourf(ax=ax, transform=ccrs.PlateCarree()) - ax.set_global() + p = air.isel(time=0).plot( + subplot_kws=dict(projection=ccrs.Orthographic(-80, 35), facecolor="gray"), + transform=ccrs.PlateCarree()) + p.axes.set_global() @savefig plotting_maps_cartopy.png width=100% - ax.coastlines() + p.axes.coastlines() When faceting on maps, the projection can be transferred to the ``plot`` function using the ``subplot_kws`` keyword. The axes for the subplots created diff --git a/doc/whats-new.rst b/doc/whats-new.rst index c7a2b85561b..43b248670f5 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -54,6 +54,9 @@ Enhancements By `Stephan Hoyer `_. - :py:meth:`DataArray.reset_index` and :py:meth:`Dataset.reset_index` now keep coordinate attributes (:pull:`4103`). By `Oriol Abril `_. +- Axes kwargs such as ``facecolor`` can now be passed to :py:meth:`DataArray.plot` in ``subplot_kws``. + This works for both single axes plots and FacetGrid plots. + By `Raphael Dussin