{"spec_id":"line-stepwise","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nline-stepwise: Step Line Plot\nLibrary: plotnine 0.15.4 | Python 3.13.13\nQuality: 82/100 | Updated: 2026-05-13\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport pandas as pd\nfrom plotnine import aes, element_line, element_rect, element_text, geom_step, ggplot, labs, theme, theme_minimal\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\"\nBRAND = \"#009E73\"\n\n# Data - Server CPU utilization showing discrete state changes\nnp.random.seed(42)\nhours = np.arange(0, 24)\n# Simulate CPU utilization that changes in discrete steps\nbase_utilization = np.array(\n    [\n        15,\n        15,\n        12,\n        10,\n        10,\n        20,  # Night/early morning - low usage\n        45,\n        65,\n        75,\n        80,\n        85,\n        80,  # Morning ramp-up - high load\n        70,\n        75,\n        80,\n        85,\n        90,\n        85,  # Afternoon - peak hours\n        70,\n        55,\n        40,\n        30,\n        25,\n        18,  # Evening wind-down\n    ]\n)\n\ndf = pd.DataFrame({\"hour\": hours, \"cpu_utilization\": base_utilization})\n\n# Theme\nanyplot_theme = theme(\n    figure_size=(16, 9),\n    plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),\n    panel_background=element_rect(fill=PAGE_BG),\n    panel_grid_major=element_line(color=INK, size=0.3, alpha=0.10),\n    panel_grid_minor=element_line(color=INK, size=0.2, alpha=0.05),\n    panel_border=element_rect(color=INK_SOFT, fill=None),\n    axis_title=element_text(size=20, color=INK),\n    axis_text=element_text(size=16, color=INK_SOFT),\n    axis_line=element_line(color=INK_SOFT),\n    plot_title=element_text(size=24, color=INK),\n)\n\n# Plot\nplot = (\n    ggplot(df, aes(x=\"hour\", y=\"cpu_utilization\"))\n    + geom_step(color=BRAND, size=2, direction=\"hv\")\n    + labs(x=\"Hour of Day\", y=\"CPU Utilization (%)\", title=\"line-stepwise · plotnine · anyplot.ai\")\n    + theme_minimal()\n    + anyplot_theme\n)\n\n# Save\nplot.save(f\"plot-{THEME}.png\", dpi=300, verbose=False)\n"}