{"spec_id":"histogram-stepwise","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nhistogram-stepwise: Step Histogram\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\nimport sys\n\n\n# Remove script directory from path to avoid matplotlib.py shadowing the matplotlib package\nscript_dir = os.path.dirname(os.path.abspath(__file__))\nsys.path = [p for p in sys.path if os.path.abspath(p) != script_dir and p not in (\"\", \".\")]\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\nBRAND = \"#009E73\"  # Position 1\nACCENT = \"#C475FD\"  # Position 2\n\n# Data - Two distributions with distinct shapes\nnp.random.seed(42)\nmc_scores = np.random.normal(loc=72, scale=8, size=250)  # Multiple Choice: symmetric\nessay_scores = np.random.beta(a=3, b=1.5, size=250) * 100  # Essay: right-skewed\nessay_scores = np.clip(essay_scores, 0, 100)\n\n# Create figure\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Step histograms (outline only, no fill)\nax.hist(mc_scores, bins=30, histtype=\"step\", linewidth=3, color=BRAND, label=\"Multiple Choice\")\nax.hist(essay_scores, bins=30, histtype=\"step\", linewidth=3, color=ACCENT, label=\"Essay Exam\", linestyle=\"--\")\n\n# Labels and styling\nax.set_xlabel(\"Score (%)\", fontsize=20, color=INK)\nax.set_ylabel(\"Number of Students\", fontsize=20, color=INK)\nax.set_title(\"histogram-stepwise · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor spine in (\"left\", \"bottom\"):\n    ax.spines[spine].set_color(INK_SOFT)\n\n# Grid\nax.yaxis.grid(True, alpha=0.10, linewidth=0.8, color=INK)\n\n# Legend with theme-adaptive styling\nleg = ax.legend(fontsize=16, loc=\"upper left\", framealpha=0.95)\nif leg:\n    leg.get_frame().set_facecolor(ELEVATED_BG)\n    leg.get_frame().set_edgecolor(INK_SOFT)\n    leg.get_frame().set_linewidth(1)\n    for text in leg.get_texts():\n        text.set_color(INK_SOFT)\n\nplt.tight_layout()\n\n# Save in the script's directory\noutput_dir = os.path.dirname(os.path.abspath(__file__))\nplt.savefig(os.path.join(output_dir, f\"plot-{THEME}.png\"), dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}