{"spec_id":"step-basic","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nstep-basic: Basic Step Plot\nLibrary: plotnine 0.15.7 | Python 3.13.14\nQuality: 90/100 | Updated: 2026-07-25\n\"\"\"\n\nimport os\n\nimport pandas as pd\nfrom plotnine import (\n    aes,\n    annotate,\n    element_blank,\n    element_line,\n    element_rect,\n    element_text,\n    geom_hline,\n    geom_point,\n    geom_step,\n    ggplot,\n    labs,\n    scale_x_continuous,\n    theme,\n    theme_minimal,\n)\n\n\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\nINK_TERTIARY = \"#6B6A63\" if THEME == \"light\" else \"#A8A79F\"\n\nBRAND = \"#009E73\"\nACCENT = \"#C475FD\"\n\n# Data - Monthly cumulative sales figures showing discrete jumps, vs. an annual target\nmonths = list(range(1, 13))\nmonth_labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\ncumulative_sales = [12, 12, 27, 27, 45, 58, 58, 73, 89, 89, 105, 120]\ntarget = 100\n\ndf = pd.DataFrame({\"month\": months, \"sales\": cumulative_sales})\n\n# Plot\nplot = (\n    ggplot(df, aes(x=\"month\", y=\"sales\"))\n    + geom_hline(yintercept=target, color=INK_SOFT, size=0.6, linetype=\"dashed\")\n    + annotate(\"text\", x=1, y=target + 5, label=f\"Annual target: {target}k\", color=INK_TERTIARY, size=6, ha=\"left\")\n    + geom_step(color=BRAND, size=1.0, direction=\"hv\")\n    + geom_point(color=ACCENT, size=2.5, stroke=0.4)\n    + scale_x_continuous(breaks=months, labels=month_labels)\n    + labs(x=\"Month\", y=\"Cumulative Sales (thousands)\", title=\"step-basic · python · plotnine · anyplot.ai\")\n    + theme_minimal()\n    + theme(\n        figure_size=(8, 4.5),\n        plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),\n        panel_background=element_rect(fill=PAGE_BG),\n        text=element_text(size=7, color=INK),\n        axis_title=element_text(size=10, color=INK),\n        axis_text=element_text(size=8, color=INK_SOFT),\n        plot_title=element_text(size=12, color=INK, weight=\"bold\"),\n        panel_grid_major=element_line(color=INK, size=0.3, alpha=0.15),\n        panel_grid_minor=element_blank(),\n        axis_line=element_line(color=INK_SOFT),\n    )\n)\n\n# Save\nplot.save(f\"plot-{THEME}.png\", dpi=400, width=8, height=4.5, units=\"in\", verbose=False)\n"}