environmentaltools.graphics.plot_mesh

environmentaltools.graphics.plot_mesh(data, levels=[-10, -1, 0, 1, 2, 5, 10, 20, 50, 100], var_='z', title=None, ax=None, fname=None, regular=False, cmap=<matplotlib.colors.LinearSegmentedColormap object>, bar_label='\\textbf{z (m)}', xlabel='\\textbf{x (m)}', ylabel='\\textbf{y (m)}', centercolormap=False, hide_colorbar=False, alpha=1)[source]

Plot mesh data with contours and color mapping.

Visualizes spatial mesh data (regular or triangular) with filled contours, optional contour lines, and customizable color mapping.

Parameters:
  • data (xarray.Dataset or dict) – Dataset containing ‘x’, ‘y’ coordinates and variable data.

  • levels (list, optional) – Contour line levels to display. If None, no contours shown. Defaults to [-10, -1, 0, 1, 2, 5, 10, 20, 50, 100].

  • var (str, optional) – Variable name to plot from data. Defaults to “z”.

  • title (str, optional) – Plot title. Defaults to None.

  • ax (matplotlib.axes.Axes, optional) – Axes object to plot on. Defaults to None.

  • fname (str, optional) – Filename to save the figure. Defaults to None.

  • regular (bool, optional) – If True, uses regular grid contouring. If False, uses triangular mesh. Defaults to False.

  • cmap (matplotlib.colors.Colormap, optional) – Colormap for filled contours. Defaults to cmocean.cm.deep_r.

  • bar_label (str, optional) – Colorbar label. Defaults to r” extbf{z (m)}”.

  • xlabel (str, optional) – X-axis label. Defaults to r” extbf{x (m)}”.

  • ylabel (str, optional) – Y-axis label. Defaults to r” extbf{y (m)}”.

  • centercolormap (bool, optional) – If True, centers colormap at zero. Defaults to False.

  • hide_colorbar (bool, optional) – If True, hides the colorbar. Defaults to False.

  • alpha (float, optional) – Transparency of filled contours (0-1). Defaults to 1.

Returns:

The axes object with the plot.

Return type:

matplotlib.axes.Axes