monet.plots.plots

plotting routines

Functions

create_taylor_diagram(df[, marker, col1, ...])

kdeplot(df[, title, label, ax])

Create a kernel density estimate plot.

make_spatial_contours(modelvar, gridobj, date, m)

Create a contour plot on a map with optional discrete colorbar.

make_spatial_plot(modelvar, m[, dpi, ...])

Create a basic spatial plot using imshow.

normval(vmin, vmax, cmap)

Create a BoundaryNorm for discrete colormaps with specific bounds.

scatter(df[, x, y, title, label, ax])

Create a scatter plot with regression line.

spatial(modelvar, **kwargs)

Create a simple spatial plot from an xarray object.

spatial_bias_scatter(df, m, date[, vmin, ...])

Create a scatter plot showing bias between model and observations on a map.

timeseries(df[, x, y, ax, plotargs, ...])

Create a timeseries plot with shaded error bounds.

wind_barbs(ws, wdir, gridobj, m, **kwargs)

Create a barbs plot of wind on a map.

wind_quiver(ws, wdir, gridobj, m, **kwargs)

Create a quiver plot of wind vectors on a map.

monet.plots.plots.create_taylor_diagram(df, marker='o', col1='obs', col2='model', label1='OBS', label2='MODEL', scale=1.5, addon=False, dia=None)
No-index:

Create a DataFrame-based Taylor diagram using the TaylorDiagram class.

A convenience wrapper for easily creating Taylor diagrams from DataFrames. For the main Taylor diagram implementation, see monet.plots.taylordiagram.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing observation and model data

  • marker (str, default “o”) – Marker style for plotting model points

  • col1 (str, default “obs”) – Column name for observations

  • col2 (str, default “model”) – Column name for model predictions

  • label1 (str, default “OBS”) – Label for observations in legend

  • label2 (str, default “MODEL”) – Label for model in legend

  • scale (float, default 1.5) – Scale factor for diagram

  • addon (bool, default False) – If True, add to existing diagram; if False, create new

  • dia (TaylorDiagram, optional) – Existing diagram to add to if addon=True

Returns:

The Taylor diagram instance

Return type:

TaylorDiagram

monet.plots.plots.kdeplot(df, title=None, label=None, ax=None, **kwargs)

Create a kernel density estimate plot.

Parameters:
  • df (pandas.Series or array-like) – Data to plot the distribution of.

  • title (str, optional) – Title for the plot.

  • label (str, optional) – Label for the plotted line (for legend).

  • ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, creates a new figure and axes.

  • **kwargs – Additional arguments passed to seaborn’s kdeplot. Common options include ‘shade’, ‘bw’, and ‘color’.

Returns:

The axes containing the plot.

Return type:

matplotlib.axes.Axes

monet.plots.plots.make_spatial_contours(modelvar, gridobj, date, m, dpi=None, savename='', discrete=True, ncolors=None, dtype='int', **kwargs)

Create a contour plot on a map with optional discrete colorbar.

Parameters:
  • modelvar (numpy.ndarray) – 2D model variable array to contour.

  • gridobj (object) – Object containing grid information with LAT and LON variables.

  • date (datetime.datetime) – Date/time for the plot title.

  • m (mpl_toolkits.basemap.Basemap) – Basemap instance for mapping.

  • dpi (int, optional) – Dots per inch for the figure if saving.

  • savename (str, default “”) – If provided, save the figure to this path with date appended.

  • discrete (bool, default True) – If True, use a discrete colorbar instead of a continuous one.

  • ncolors (int, optional) – Number of discrete colors when using discrete colorbar.

  • dtype (str, default “int”) – Data type for colorbar tick labels.

  • **kwargs – Additional arguments to pass to contourf. Must include ‘cmap’ and ‘levels’.

Returns:

The colorbar instance.

Return type:

matplotlib.colorbar.Colorbar

monet.plots.plots.make_spatial_plot(modelvar, m, dpi=None, plotargs={}, ncolors=15, discrete=False)

Create a basic spatial plot using imshow.

Parameters:
  • modelvar (numpy.ndarray) – 2D model variable array to plot.

  • m (mpl_toolkits.basemap.Basemap) – Basemap instance for mapping.

  • dpi (int, optional) – Dots per inch for the figure. Higher values increase resolution.

  • plotargs (dict, default {}) – Additional arguments to pass to imshow. Common options include ‘cmap’, ‘vmin’, ‘vmax’, and ‘alpha’.

  • ncolors (int, default 15) – Number of discrete colors when using discrete colorbar.

  • discrete (bool, default False) – If True, use a discrete colorbar instead of a continuous one.

Returns:

(figure, axes, colorbar, colormap, vmin, vmax) - figure: matplotlib Figure instance - axes: matplotlib Axes instance - colorbar: matplotlib Colorbar instance - colormap: matplotlib Colormap instance - vmin, vmax: minimum and maximum values for the colormap

Return type:

tuple

monet.plots.plots.normval(vmin, vmax, cmap)

Create a BoundaryNorm for discrete colormaps with specific bounds.

Parameters:
  • vmin (float) – Minimum value for the colormap.

  • vmax (float) – Maximum value for the colormap.

  • cmap (matplotlib.colors.Colormap) – The colormap to create bounds for.

Returns:

A boundary norm with evenly spaced bounds from vmin to vmax in steps of 5.0.

Return type:

matplotlib.colors.BoundaryNorm

monet.plots.plots.scatter(df, x=None, y=None, title=None, label=None, ax=None, **kwargs)

Create a scatter plot with regression line.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing the data to plot.

  • x (str, optional) – Column name for x-axis values.

  • y (str, optional) – Column name for y-axis values.

  • title (str, optional) – Title for the plot.

  • label (str, optional) – Label for the plot (for legend).

  • ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, creates a new figure and axes.

  • **kwargs – Additional arguments passed to seaborn’s regplot. Common options include ‘scatter_kws’, ‘line_kws’, and ‘ci’.

Returns:

The axes containing the plot.

Return type:

matplotlib.axes.Axes

monet.plots.plots.spatial(modelvar, **kwargs)

Create a simple spatial plot from an xarray object.

A convenience wrapper for xarray’s plot method with consistent styling.

Parameters:
  • modelvar (xarray.DataArray) – The data to plot spatially.

  • **kwargs – Additional keyword arguments passed to xarray’s plot method. If ‘ax’ is not provided, a new figure and axes will be created.

Returns:

The axes containing the plot.

Return type:

matplotlib.axes.Axes

monet.plots.plots.spatial_bias_scatter(df, m, date, vmin=None, vmax=None, savename='', ncolors=15, fact=1.5, cmap='RdBu_r')

Create a scatter plot showing bias between model and observations on a map.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing ‘latitude’, ‘longitude’, ‘CMAQ’, and ‘Obs’ columns.

  • m (mpl_toolkits.basemap.Basemap) – Basemap instance for mapping.

  • date (str or datetime.datetime) – Date to filter the DataFrame. Only entries matching this date will be plotted.

  • vmin (float, optional) – Minimum value for colorscale. If None, automatically determined.

  • vmax (float, optional) – Maximum value for colorscale. If None, automatically determined.

  • savename (str, default “”) – If provided, save the figure to this path with date appended.

  • ncolors (int, default 15) – Number of discrete colors for the colorbar.

  • fact (float, default 1.5) – Scaling factor for point sizes.

  • cmap (str or matplotlib.colors.Colormap, default “RdBu_r”) – Colormap to use for bias values.

Returns:

(figure, axes, colorbar) containing the matplotlib objects.

Return type:

tuple

Notes

The scatter points are colored by the difference (CMAQ - Obs) and sized by the absolute magnitude of this difference, making larger biases more visible.

monet.plots.plots.timeseries(df, x='time', y='obs', ax=None, plotargs={}, fillargs={'alpha': 0.2}, title='', ylabel=None, label=None)

Create a timeseries plot with shaded error bounds.

Parameters:
  • df (pandas.DataFrame) – DataFrame containing the data to plot.

  • x (str, default “time”) – Column name to use for the x-axis (time).

  • y (str, default “obs”) – Column name to use for the y-axis (values to plot).

  • ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, creates a new figure and axes.

  • plotargs (dict, default {}) – Additional arguments to pass to DataFrame.plot().

  • fillargs (dict, default {“alpha”: 0.2}) – Additional arguments to pass to fill_between for the error shading.

  • title (str, default “”) – Title for the plot.

  • ylabel (str, optional) – Y-axis label. If None, uses variable name and units from DataFrame.

  • label (str, optional) – Label for the plotted line (for legend). If None, uses y.

Returns:

The axes containing the plot.

Return type:

matplotlib.axes.Axes

Notes

This function groups the data by time, plots the mean values, and adds shading for ±1 standard deviation around the mean.

monet.plots.plots.wind_barbs(ws, wdir, gridobj, m, **kwargs)

Create a barbs plot of wind on a map.

Parameters:
  • ws (numpy.ndarray) – 2D array of wind speeds.

  • wdir (numpy.ndarray) – 2D array of wind directions (meteorological convention, degrees).

  • gridobj (object) – Object containing grid information with LAT and LON variables.

  • m (mpl_toolkits.basemap.Basemap) – Basemap instance for mapping.

  • **kwargs – Additional arguments to pass to barbs. Common options include ‘length’, ‘pivot’, and ‘barb_increments’.

Return type:

None

monet.plots.plots.wind_quiver(ws, wdir, gridobj, m, **kwargs)

Create a quiver plot of wind vectors on a map.

Parameters:
  • ws (numpy.ndarray) – 2D array of wind speeds.

  • wdir (numpy.ndarray) – 2D array of wind directions (meteorological convention, degrees).

  • gridobj (object) – Object containing grid information with LAT and LON variables.

  • m (mpl_toolkits.basemap.Basemap) – Basemap instance for mapping.

  • **kwargs – Additional arguments to pass to quiver. Common options include ‘scale’, ‘scale_units’, and ‘width’.

Returns:

The quiver instance.

Return type:

matplotlib.quiver.Quiver