xoa.plot.plot_vectors

Contents

xoa.plot.plot_vectors#

xoa.plot.plot_vectors(u, v, ax=None, stride='auto', min_spacing=None, color='k', key=True, key_pos=None, transform=None, margin=0.0, map_kw=None, title=None, ustd=None, vstd=None, uvcorr=None, nsigma=2.45, ellipse_kwargs=None, **kwargs)[source]#

Plot currents on a map as arrows, under-sampled to stay readable

Longitudes and latitudes are found with xoa.coords.get_lon() and xoa.coords.get_lat(). The arrows are drawn in geographic directions whatever the projection and the orientation of the grid.

Parameters:
  • u (xarray.DataArray) – Zonal and meridional velocities on the same grid, with no other dimension than the horizontal ones.

  • v (xarray.DataArray) – Zonal and meridional velocities on the same grid, with no other dimension than the horizontal ones.

  • ax (None, cartopy.mpl.geoaxes.GeoAxes) – Axes to plot on, that may already hold a field. A map is created if not provided.

  • stride (str, int, tuple(int)) – Under-sampling of the arrows, either one value for both directions or a (y, x) tuple. With "auto", the stride is adapted to the size of the axes so that there are at least min_spacing pixels between consecutive arrows.

  • min_spacing (None, float) – Minimal spacing in pixels between arrows in the "auto" stride mode, which defaults to the plot.vectors_min_spacing option.

  • color (color, "speed") – Color of the arrows, or "speed" to color them with the speed, in which case a colorbar is added unless add_colorbar=False is passed.

  • key (bool, str, None) – Add a reference arrow that is labelled with its speed, whose round value is given by xoa.core.plot.get_quiverkey_value(). A string is used as the label units, which default to the ones of u.

  • key_pos (None, tuple(float)) – Position of the reference arrow in axes coordinates, which defaults to the plot.key_pos option

  • transform (None, cartopy.crs.CRS) – Coordinate system of the field, which defaults to PlateCarree

  • margin (float) – Margin added to the extent of a new map. See xoa.geo.get_extent().

  • map_kw (None, dict) – Parameters that decorate the map. See plot_field().

  • title (None, str)

  • ustd (None, xarray.DataArray) – Standard deviation of u on the same grid. When provided, an uncertainty ellipse is drawn at the tip of each arrow, see xoa.core.plot.plot_vector_ellipses(). It is available as the ellipses attribute of the returned quiver.

  • vstd (None, xarray.DataArray) – Standard deviation of v, which defaults to ustd

  • uvcorr (None, xarray.DataArray) – Correlation between u and v, which defaults to zero

  • nsigma (float) – Radius of the ellipses in standard deviations. The default includes 95% of a gaussian distribution in 2D, while 2 only includes 86%.

  • ellipse_kwargs (None, dict) – Parameters of the ellipses, like facecolor, edgecolor or label. They are drawn with the color of the arrows, with a transparent face, unless the arrows are colored by speed.

  • kwargs – Extra parameters are passed to xoa.core.plot.plot_vectors(), like scale, width, cmap or alpha. The scale is adapted by default to the spacing between arrows. With color="speed", add_colorbar and cbar_kwargs are also accepted.

Returns:

matplotlib.quiver.Quiver

Example

ax = plot_field(speed, cmap="cmo.speed")
plot_vectors(u, v, ax=ax, color="w", scale=20)