csep.plots.plot_test_distribution

csep.plots.plot_test_distribution(evaluation_result, bins='fd', percentile=95, auto_annotate=True, sim_label='Simulated', obs_label='Observation', legend=True, ax=None, show=False, **kwargs)[source]

Plots the histogram of a test statistic distribution calculated from stochastic event sets along with the observed statistic.

Parameters:
  • evaluation_result (EvaluationResult) – Result containing test distributions and observed statistics.

  • bins (str, int, or list, optional) – Binning strategy for the histogram. See matplotlib.pyplot.hist() for details on this parameter. Defaults to ‘fd’.

  • percentile (int, optional) – Percentile for shading regions. Defaults to 95.

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

  • auto_annotate (bool or dict, optional) – If True, automatically formats the plot details based on the evaluation result. It can be further customized by passing the keyword arguments xlabel, ylabel, annotation_text, annotation_xy, and annotation_fontsize. Defaults to True.

  • sim_label (str, optional) – Label for the simulated data. Defaults to ‘Simulated’.

  • obs_label (str, optional) – Label for the observation data. Defaults to ‘Observation’.

  • legend (bool, optional) – Whether to display the legend. Defaults to True.

  • show (bool, optional) – If True, shows the plot. Defaults to False.

  • **kwargs (optional) –

    Additional keyword arguments for plot customization.

    • color (str): Color of the histogram bars.

    • alpha (float): Transparency level for the histogram bars.

    • figsize (tuple): The size of the figure.

    • xlim (tuple): Limits for the X-axis.

    • grid (bool): Whether to display grid lines. Defaults to True.

    • legend_loc (str): Location of the legend. Defaults to ‘best’.

    • legend_fontsize (int): Font size of the legend text.

    • xlabel (str): Label of the X-axis. If auto_annotate is True, will be set to the test statistic name.

    • ylabel (str): Label of the Y-axis.

    • annotate_text (str): Text to annotate the plot with. If auto_annotate is True, it will provide information about the statistics of the test.

    • annotate_xy (tuple): Position for annotate_text in axes fraction. Can be used to override position of auto_annotate if not optimal.

    • annotate_fontsize (int): Size of the annotation.

    • tight_layout (bool): Whether to use tight layout for the figure. Defaults to True.

Returns:

Matplotlib axes handle.

Return type:

matplotlib.axes.Axes

Changed in version 0.8.0: This function was renamed from plot_distribution_test and replaces plot_spatial_test, plot_number_test, plot_magnitude_test and plot_likelihood_test. plot_args dictionary is only partially supported and will be removed in v1.0.0.

Added in version 0.8.0: Added auto_annotate function to detect which test is being plotted and write down labels and quantiles accordingly.