csep.plots.plot_magnitude_histogram
- csep.plots.plot_magnitude_histogram(forecast, observation=None, magnitude_bins=None, percentile=95, log_scale=True, normalize=True, cumulative=False, intervals=True, ax=None, show=False, **kwargs)[source]
Generates a semi-log magnitude histogram comparing a catalog-based forecast with observed data. The forecast’s mean and uncertainty intervals are displayed along with the observed event counts.
Usage Tutorials
- Parameters:
forecast (CatalogForecast or list of CSEPCatalog or GriddedForecast) – A forecast or a list of observed catalogs.
observation (CSEPCatalog) – The observed catalog for comparison.
magnitude_bins (list of float or numpy.ndarray, optional) – The bins for magnitude histograms. If None, defaults to the region magnitudes or standard CSEP bins. Defaults to None.
percentile (int, optional) – The percentile used for uncertainty intervals. Defaults to 95.
log_scale (bool, optional) – Whether to plot the y-axis in logarithmic scale. Defaults to True.
normalize (bool, optional) – Whether to normalize the forecast for the total number in the observation catalog.
cumulative (bool, optional) – Whether to plot cumulative counts N(M >= m). Defaults to False.
intervals (bool, optional) – Whether to display forecast uncertainty intervals. Defaults to True.
ax (matplotlib.axes.Axes, optional) – The axes object to draw the plot on. If None, a new figure and axes are created. Defaults to None.
show (bool, optional) – Whether to display the plot immediately. Defaults to False.
**kwargs (optional) –
Additional keyword arguments to customize the plot:
figsize (tuple): The size of the figure.
color (str): Color for the observed histogram points.
markersize (int): Size of the markers in the plot. Defaults to 6.
capsize (float): Size of the error bar caps. Defaults to 4.
linewidth (float): Width of the error bar lines. Defaults to 1.5.
xlim (tuple): Limits for the X-axis.
xlabel (str): Label for the X-axis. Defaults to ‘Magnitude’.
xlabel_fontsize (int): Font size for the X-axis label.
ylabel (str): Label for the Y-axis. Defaults to ‘Event count’.
ylabel_fontsize (int): Font size for the Y-axis label.
title (str): Title of the plot. Defaults to ‘Magnitude Histogram’.
title_fontsize (int): Font size for the plot title.
grid (bool): Whether to show grid lines. Defaults to True.
legend_loc (str): Location of the legend. Defaults to ‘best’.
legend_fontsize (int): Font size of the legend text.
tight_layout (bool): Whether to use tight layout for the figure. Defaults to True.
- Returns:
The axes object containing the plot.
- Return type:
Changed in version 0.8.0: It now accepts a CatalogForecast or a GriddedForecast. An obervation CSEPCatalog is now optional. Added magnitude_bins, percentile and log_scale to fine-tune the plot. Added parameters to customize coloring, formatting and sizing of the plot elements. The plot_args dictionary is only partially supported and will be removed in v1.0.0