pyobsmod.plots.scatter_plot_joint#

pyobsmod.plots.scatter_plot_joint(obs: ndarray, mod: ndarray, which_stats: Sequence[str] | dict[str, Any] | None = None, names: Sequence[str] | None = None, fmt: str | Sequence[str] = '.2f', nbins: int = 8, rfreqs: list[float] = [0, 0.2, 0.4], ax: Axes | None = None, idline_kws: dict[str, Any] | None = None, regline_kws: dict[str, Any] | None = None, textbox_kws: dict[str, Any] | None = None, **kwargs) tuple[Axes, Axes, Axes]#

Scatter plot sns observed data against modelled data.

Add an identity line and display selected statistics with seaborn’s jointplot.

Internally this function create a Dataset object and passes the arguments to the Dataset.scatter_plot_joint method.

Parameters:
  • obs (numpy.ndarray) – 1d numpy array that contains the data that was observed / measured.

  • mod (numpy.ndarray) – 1d numpy array that contains the data that was predicted / modelled.

  • which_stats (Sequence[str] | dict[str, Any] | None) – Sequence of the statistics parameters to compute or alternatively a dictionary with the statistics parameters as keys and the arguments that are passed to the method as values.

  • names (Sequence[str] | None) – Sequence of the names of the statistics parameters. If None, the names are taken from the keys of the which_stats dictionary.

  • fmt (str | Sequence[str]) – Format string for the statistics. Can be a single string that is used for all statistics or a sequence of strings that is used for

  • nbins (int) – Number of bins for the histograms.

  • rfreqs (list[float]) – List of relative frequencies for the ticks on the histograms.

  • ax (plt.Axes | None) – Matplotlib axis to draw the plot on.

  • idline_kws (dict[str, Any] | None) – Dictionary that is passed to matplotlib.pyplot.axline for the identity line.

  • regline_kws (dict[str, Any] | None) – Dictionary that is passed to matplotlib.pyplot.axline for the regression line.

  • textbox_kws (dict[str, Any] | None) – Dictionary that is passed to matplotlib.pyplot.AnchoredText.

  • **kwargs – Additional arguments that are passed to matplotlib.pyplot.scatter.

Returns:

axs – The matplotlib axes of the scatter plot and both histograms.

Return type:

tuple[matplotlib.pyplot.Axes, matplotlib.pyplot.Axes, matplotlib.pyplot.Axes]

Examples

import matplotlib.pyplot as plt
import numpy as np
import pyobsmod.plots as pp

obs = np.sin(np.arange(100)) + np.random.normal(size=100)
mod = np.sin(np.arange(100)) + np.random.normal(size=100)

axs = pp.scatter_plot_joint(obs, mod, ['bias', 'rmse', 'nrmse', 'r2'])
# You can (but don't have to) access the individual axes
ax, ax_histx, ax_histy = axs
plt.show()
../../_images/pyobsmod.plots.scatter_plot_joint_0_0.png