in src/graphing/heatmap.py [0:0]
def plot_heatmap(heatmap, dimensions, labels=True):
width = dimensions[0] # x_bucket_count
height = dimensions[1] # y_bucket_count
max_pause_ms = height * dimensions[3]
max_time_ms = width * dimensions[2]
min_time_ms = dimensions[4]
multipler = max_time_ms / width # multipler is the size of a bucket for time direction
# x labels are the time labels
time_labels = [num * multipler + min_time_ms for num in range(1, width + 1)] # TODO : UPDATE TO BE FASTER
time_labels_temp = []
for i in range(len(time_labels)):
if not i % 2:
time_labels_temp.append(str(round(time_labels[i], 2)) + " s")
else:
time_labels_temp.append("")
# time_labels = [str(round(label, 2)) + " s" for label in time_labels]
time_labels = time_labels_temp
# size of the buckets for ms pause
multipler = (max_pause_ms) / height
# y labels are ms pause time labels
latency_labels = [round((num * multipler), 2) for num in reversed(range(1, height + 1))]
latency_labels = [str(label) + " ms" for label in latency_labels]
## Create a figure, and add data to heatmap. Plot then show heatmap.
fig, ax = plt.subplots()
ax.set_title("Latency during runtime.")
# cmap is the color scheme. To change the heatmap color scheme, use a color scheme from here:
# https://matplotlib.org/stable/tutorials/colors/colormaps.html
im = __heatmap_make(heatmap, latency_labels, time_labels, ax=ax, cmap="plasma", cbarlabel="Frequency", fig = fig)
if labels:
__annotate_heatmap(im, valfmt="{x}")
fig.tight_layout()
return ax