{"spec_id":"line-stepwise","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nline-stepwise: Step Line Plot\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-13\n\"\"\"\n\nimport os\nimport pathlib\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\n# Okabe-Ito palette (first series is always brand green)\nBRAND = \"#009E73\"\nSECONDARY = \"#C475FD\"\n\n# Data: Server capacity levels over monitoring period\nnp.random.seed(42)\nhours = np.arange(0, 24, 1)\n\n# Server capacity changes at discrete intervals\ncapacity = np.array(\n    [\n        50,\n        50,\n        50,\n        50,\n        50,\n        50,  # Night: low capacity\n        75,\n        75,\n        100,\n        100,\n        100,\n        100,  # Morning ramp-up\n        150,\n        150,\n        150,\n        125,\n        125,\n        100,  # Peak hours, then decline\n        100,\n        75,\n        75,\n        75,\n        50,\n        50,  # Evening wind-down\n    ]\n)\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Step plot with 'post' alignment - value persists until next point\nax.step(hours, capacity, where=\"post\", linewidth=3.5, color=BRAND, label=\"Server Capacity\")\n\n# Add markers at change points to show discrete values\nax.scatter(hours, capacity, s=150, color=BRAND, edgecolors=PAGE_BG, linewidths=1.5, zorder=5)\n\n# Fill under the step curve for visual emphasis\nax.fill_between(hours, capacity, step=\"post\", alpha=0.15, color=BRAND)\n\n# Style\nax.set_xlabel(\"Hour of Day\", fontsize=20, color=INK)\nax.set_ylabel(\"Server Capacity (units)\", fontsize=20, color=INK)\nax.set_title(\"line-stepwise · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Set axis limits with padding\nax.set_xlim(-0.5, 23.5)\nax.set_ylim(0, 175)\n\n# Configure x-axis ticks for hours\nax.set_xticks(np.arange(0, 24, 2))\nax.set_xticklabels([f\"{h:02d}:00\" for h in range(0, 24, 2)])\n\n# Remove top and right spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor s in (\"left\", \"bottom\"):\n    ax.spines[s].set_color(INK_SOFT)\n\n# Subtle grid\nax.yaxis.grid(True, alpha=0.10, linewidth=0.8, color=INK_SOFT)\n\n# Legend styling\nleg = ax.legend(fontsize=16, loc=\"upper right\")\nif leg:\n    leg.get_frame().set_facecolor(ELEVATED_BG)\n    leg.get_frame().set_edgecolor(INK_SOFT)\n    plt.setp(leg.get_texts(), color=INK_SOFT)\n\nplt.tight_layout()\n\n# Save to implementation directory\noutput_dir = pathlib.Path(__file__).parent\nplt.savefig(output_dir / f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}