6.2.10.2. eqcorrscan.utils.plotting.cumulative_detections¶
- eqcorrscan.utils.plotting.cumulative_detections(dates=None, template_names=None, detections=None, plot_grouped=False, group_name=None, rate=False, binsize=None, plot_legend=True, ax=None, **kwargs)[source]¶
Plot cumulative detections or detection rate in time.
Simple plotting function to take a list of either datetime objects or
eqcorrscan.core.match_filter.Detection
objects and plot a cumulative detections list. Can take dates as a list of lists and will plot each list separately, e.g. if you have dates from more than one template it will overlay them in different colours.- Parameters:
dates (list) – Must be a list of lists of datetime.datetime objects
template_names (list) – List of the template names in order of the dates
detections (list) – List of
eqcorrscan.core.match_filter.Detection
plot_grouped (bool) – Plot detections for each template individually, or group them all together - set to False (plot template detections individually) by default.
group_name (str) – Name to put in legend for the group, only used if plot_grouped=True
rate (bool) – Whether or not to plot the rate of detection per day. Only works for plot_grouped=True
binsize (int) – Bin size for rate plotting in seconds.
plot_legend (bool) – Specify whether to plot legend of template names. Defaults to True.
ax (matplotlib.pyplot.Axis) – Axis to plot into, if you want to re-use a figure.
title (str) – Title of figure
show (bool) – Whether to show the figure or not (defaults to True)
save (bool) – Whether to save the figure or not (defaults to False)
savefile (str) – Filename to save figure to, if save==True (defaults to “EQcorrscan_figure.png”)
return_figure (bool) – Whether to return the figure or not (defaults to True), if False then the figure will be cleared and closed.
size (tuple of float) – Figure size as (width, height) in inches. Defaults to (10.5, 7.5)
- Returns:
Note
Can either take lists of
eqcorrscan.core.match_filter.Detection
objects directly, or two lists of dates and template names - either/or, not both.Example
>>> import datetime as dt >>> import numpy as np >>> from eqcorrscan.utils.plotting import cumulative_detections >>> dates = [] >>> for i in range(3): ... dates.append([dt.datetime(2012, 3, 26) + dt.timedelta(n) ... for n in np.random.randn(100)]) >>> cumulative_detections(dates, ['a', 'b', 'c'], ... show=True)
Example 2: Rate plotting
>>> import datetime as dt >>> import numpy as np >>> from eqcorrscan.utils.plotting import cumulative_detections >>> dates = [] >>> for i in range(3): ... dates.append([dt.datetime(2012, 3, 26) + dt.timedelta(n) ... for n in np.random.randn(100)]) >>> cumulative_detections(dates, ['a', 'b', 'c'], plot_grouped=True, ... rate=True, show=True)