in src/lookoutequipment/plot.py [0:0]
def plot_histogram_comparison(timeseries_1,
timeseries_2,
ax=None,
label_timeseries_1=None,
label_timeseries_2=None,
show_legend=True,
num_bins=10
):
"""
Takes two timeseries and plot a histogram showing their respective
distribution of values
Parameters:
timeseries_1 (array_like):
The first time series to plot a histogram for
timeseries_2 (array_like):
The second time series to plot a histogram for
ax (matplotlib.pyplot.Axis):
The ax in which to render the range plot. If None, this
function will create a figure and an ax. Default to
None
label_timeseries_1 (string):
The label for the first time series
label_timeseries_2 (string):
The label for the second time series
show_legend (Boolean):
True to display a legend on this histogram plot and False
otherwise
num_bins (integer):
Number of bins to compute (defaults to 10)
"""
bins = compute_bin_edges([timeseries_1, timeseries_2], num_bins=num_bins)
if ax is None:
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.hist(timeseries_1,
density=True,
alpha=0.5,
bins=bins,
edgecolor='#FFFFFF',
color='tab:red',
label=label_timeseries_1)
ax.hist(timeseries_2,
density=True,
alpha=0.5,
bins=bins,
edgecolor='#FFFFFF',
color='tab:blue',
label=label_timeseries_2)
ax.grid(False)
ax.get_yaxis().set_visible(False)
if (show_legend) and \
(label_timeseries_1 is not None) and \
(label_timeseries_2 is not None):
ax.legend(framealpha=0.5)
return ax