from pathlib import Path import matplotlib import matplotlib.pyplot as plt import numpy as np queues = np.array( [ [42, 35, 29, 21, 18], [55, 48, 40, 32, 24], [38, 44, 51, 46, 39], [26, 31, 37, 43, 49], ] ) teams = ["Platform", "Security", "Billing", "Support"] days = ["Mon", "Tue", "Wed", "Thu", "Fri"] output = Path("heatmap-create.png") fig, ax = plt.subplots(figsize=(6.6, 4.2), layout="constrained") image = ax.imshow(queues, cmap="magma", vmin=15, vmax=60) ax.set_title("Open support tickets by team") ax.set_xlabel("Day") ax.set_ylabel("Team") ax.set_xticks(range(len(days)), days) ax.set_yticks(range(len(teams)), teams) colorbar = fig.colorbar(image, ax=ax, label="Open tickets") for row in range(queues.shape[0]): for column in range(queues.shape[1]): value = queues[row, column] text_color = "white" if image.norm(value) < 0.45 else "black" ax.text(column, row, value, ha="center", va="center", color=text_color) fig.savefig(output, dpi=160) plt.close(fig) matplotlib_version = matplotlib.__version__.split("+", 1)[0] print(f"matplotlib {matplotlib_version}") print(f"matrix shape: {queues.shape[0]} rows x {queues.shape[1]} columns") print(f"colorbar label: {colorbar.ax.get_ylabel()}") print(f"saved: {output}") print(f"bytes: {output.stat().st_size}")