in src/graphing/plotting.py [0:0]
def plot_frequency_of_gc_intervals(
gc_event_dataframes,
group_by=None,
filter_by=None,
labels=None,
colors=None,
plot=None,
column="GCIndex", # Used to determine uniqueness of GC events
interval_duration = 0,
column_timing = None
):
if not interval_duration:
print("No interval length provided. Abort.")
return
timestamp_groups, datapoint_groups, labels, colors, _ = filter_and_group(
gc_event_dataframes, group_by, filter_by, labels, column, colors, column_timing)
# # if no plot is passed in, create a new plot
if not plot:
f, plot = plt.subplots()
number_of_buckets, min_time_duration, _ = get_buckets_and_range(timestamp_groups, interval_duration)
# Determine the spacing along the X axis for the data
x_alignment = [idx * interval_duration + min_time_duration for idx in range(number_of_buckets)]
if len(timestamp_groups) > len(labels):
print("Not enough labels to plot")
if len(datapoint_groups) > len(colors):
print("Not enough colors to plot")
# Create a list of frequencies, one for each group, and plot that line
for index, (timestamps, dataset) in enumerate(zip(timestamp_groups, datapoint_groups)):
# First, group into buckets based on time interverals.
buckets = group_into_buckets([time - min_time_duration for time in timestamps], dataset, number_of_buckets, interval_duration)
# Calculate the frequency of gc events per bucket time interval. Then plot
frequency = [len(set(bucket)) for bucket in buckets] # Based on frequency of UNIQUE VALUES
plot.plot(x_alignment, frequency, label = labels[index], color = colors[index])
# Add styling to the plot. Add legend, and correct x-axis labels
plot.legend(bbox_to_anchor=(1.05, 1), loc="upper left")
return plot