from pathlib import Path import matplotlib.pyplot as plt months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] created = [34, 38, 41, 46, 44, 49] resolved = [30, 35, 39, 42, 45, 47] escalated = [6, 5, 8, 7, 6, 4] satisfaction = [82, 84, 83, 86, 88, 90] fig, axs = plt.subplots( 2, 2, figsize=(8.8, 5.6), sharex=True, squeeze=False, layout="constrained", ) fig.suptitle("Support queue dashboard") axs[0, 0].plot(months, created, marker="o", color="tab:blue") axs[0, 0].set_title("Tickets created") axs[0, 0].set_ylabel("Tickets") axs[0, 1].bar(months, resolved, color="tab:green") axs[0, 1].set_title("Tickets resolved") axs[0, 1].set_ylabel("Tickets") axs[1, 0].plot(months, escalated, marker="s", color="tab:red") axs[1, 0].set_title("Escalations") axs[1, 0].set_xlabel("Month") axs[1, 0].set_ylabel("Tickets") axs[1, 1].plot(months, satisfaction, marker="^", color="tab:purple") axs[1, 1].set_title("Satisfaction score") axs[1, 1].set_xlabel("Month") axs[1, 1].set_ylabel("Score") axs[1, 1].set_ylim(75, 95) for ax in axs.flat: ax.grid(True, axis="y", alpha=0.25) output = Path("support-subplots.png") fig.savefig(output, dpi=160) plt.close(fig) titles = ", ".join(ax.get_title() for ax in axs.flat) shared_x = axs[0, 0].get_shared_x_axes().joined(axs[0, 0], axs[1, 1]) print(f"axes grid: {axs.shape[0]} rows x {axs.shape[1]} columns") print(f"axes titles: {titles}") print(f"shared x-axis: {shared_x}") print(f"saved: {output}") print(f"bytes: {output.stat().st_size}")