pyobsmod.plots.time_series_plot#

pyobsmod.plots.time_series_plot(obs: ndarray, mod: ndarray, time: ndarray | Index | DatetimeIndex | None = None, which_stats: Sequence[str] | dict[str, Any] | None = None, names: Sequence[str] | None = None, fmt: str | Sequence[str] = '.2f', ax: Axes | None = None, textbox_kws: dict[str, Any] | None = None, obs_kws: dict[str, Any] | None = None, mod_kws: dict[str, Any] | None = None, **kwargs) Axes#

Time series plot of observed data against modelled data.

Display selected statistics.

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

Parameters:
  • obs (numpy.ndarray) – Observation data. Should preferably be a 1-dimensional numpy.ndarray, but lists and tuples can be passed as well.

  • mod (numpy.ndarray) – Predicted / modelled data. Should preferably be a 1-dimensional numpy.ndarray, but lists and tuples can be passed as well.

  • time (numpy.ndarray | pandas.Index | pandas.DatetimeIndex | None) – A 1-dimensional array with the time steps of the observation and modelled data. Will be used automatically as ticks in certain plots like Dataset.time_series_plot.

  • 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

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

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

  • obs_kws (dict[str, Any] | None) – Dictionary that is passed to the observation data matplotlib.pyplot.plot call.

  • mod_kws (dict[str, Any] | None) – Dictionary that is passed to the modelled data matplotlib.pyplot.plot call.

  • **kwargs – Additional arguments that are passed to both matplotlib.pyplot.plot calls.

Returns:

ax – The Matplotlib axes.

Return type:

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)
ax = pp.time_series_plot(
        obs, mod, which_stats=['bias', 'rmse', 'nrmse', 'r2']
    )
plt.show()
../../_images/pyobsmod.plots.time_series_plot_0_0.png