from pathlib import Path import matplotlib.pyplot as plt import numpy as np queue_counts = np.array( [ [42, 35, 29, 21, 18], [55, 48, 40, 32, 24], [38, 44, 51, 46, 39], [26, 31, 37, 43, 49], ] ) row_labels = ["Platform", "Security", "Billing", "Support"] column_labels = ["Mon", "Tue", "Wed", "Thu", "Fri"] output_path = Path("heatmap-create.png") fig, ax = plt.subplots(figsize=(6.6, 4.2), layout="constrained") image = ax.imshow(queue_counts, 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(column_labels)), labels=column_labels) ax.set_yticks(range(len(row_labels)), labels=row_labels) fig.colorbar(image, ax=ax, label="Open tickets") for row_index, row in enumerate(queue_counts): for column_index, value in enumerate(row): text_color = "black" if image.norm(value) > 0.62 else "white" ax.text( column_index, row_index, value, ha="center", va="center", color=text_color, ) fig.savefig(output_path, dpi=160) plt.close(fig) print(f"matrix: {queue_counts.shape[0]} rows x {queue_counts.shape[1]} columns") print(f"range: {queue_counts.min()} to {queue_counts.max()}") print(f"saved: {output_path}")