import matplotlib.pyplot as plt from matplotlib.colors import to_hex months = ["Jan", "Feb", "Mar", "Apr", "May"] planned = [4, 5, 6, 7, 8] actual = [3, 6, 5, 8, 9] palette = { "line": "tab:blue", "marker_face": "#ffbf00", "marker_edge": (0.0, 0.2, 0.4), "bars": "C2", "fill": (0.2, 0.6, 0.9, 0.25), } fig, ax = plt.subplots(layout="constrained") (actual_line,) = ax.plot( months, actual, color=palette["line"], marker="o", markerfacecolor=palette["marker_face"], markeredgecolor=palette["marker_edge"], linewidth=2.5, label="Actual", ) bars = ax.bar( months, planned, color=palette["bars"], edgecolor="#1f2937", alpha=0.35, label="Plan", ) band = ax.fill_between( months, [value - 1 for value in actual], [value + 1 for value in actual], color=palette["fill"], label="Range", ) ax.set_title("Revenue plan and actuals") ax.set_ylabel("Revenue ($k)") ax.legend() fig.savefig("plot-color-set.png", dpi=160) print(f"line color: {to_hex(actual_line.get_color())}") print(f"marker face: {to_hex(actual_line.get_markerfacecolor())}") print(f"marker edge: {to_hex(actual_line.get_markeredgecolor())}") print(f"bar face: {to_hex(bars.patches[0].get_facecolor())}") print(f"fill face: {to_hex(band.get_facecolor()[0], keep_alpha=True)}") print("saved: plot-color-set.png")