{"spec_id":"ecdf-basic","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\necdf-basic: Basic ECDF Plot\nLibrary: matplotlib 3.11.0 | Python 3.13.14\nQuality: 91/100 | Updated: 2026-06-25\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\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\"\nINK_MUTED = \"#6B6A63\" if THEME == \"light\" else \"#A8A79F\"\nBRAND = \"#009E73\"  # Imprint palette position 1\n\n# Data: IoT sensor temperature readings (°C) — bimodal mix of offices and server rooms\nnp.random.seed(7)\noffice = np.random.normal(loc=22.0, scale=1.8, size=160)\nservers = np.random.normal(loc=18.5, scale=0.9, size=90)\ntemps = np.concatenate([office, servers])\nt_min = temps.min()\n\n# Canvas — 3200 × 1800 px landscape (figsize × dpi, no bbox_inches='tight')\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Subtle fill under the ECDF curve for visual weight\nsorted_temps = np.sort(temps)\necdf_y = np.arange(1, len(sorted_temps) + 1) / len(sorted_temps)\nax.fill_between(sorted_temps, 0, ecdf_y, step=\"post\", alpha=0.10, color=BRAND)\n\n# ECDF step function (drawn on top of fill)\nax.ecdf(temps, color=BRAND, linewidth=2.5)\n\n# Bimodal mode markers — highlight the two sensor populations\nfor mode_temp, label in [(18.5, \"Server\\nrooms\"), (22.0, \"Offices\")]:\n    ax.axvline(mode_temp, color=INK_MUTED, linestyle=\"--\", linewidth=0.8, alpha=0.45)\n    ax.text(mode_temp + 0.2, 0.05, label, fontsize=8, color=INK_MUTED, va=\"bottom\", ha=\"left\")\n\n# Quartile reference guides (Q1, Q2, Q3)\nquartiles = [25, 50, 75]\nq_values = np.percentile(temps, quartiles)\nfor q, v in zip(quartiles, q_values, strict=True):\n    yf = q / 100\n    ax.plot([t_min - 0.3, v], [yf, yf], color=INK_MUTED, linestyle=\":\", linewidth=0.8, alpha=0.6)\n    ax.plot([v, v], [0, yf], color=INK_MUTED, linestyle=\":\", linewidth=0.8, alpha=0.6)\n    ax.annotate(\n        f\"Q{q // 25}  {v:.1f}°C\", xy=(v, yf), xytext=(5, 5), textcoords=\"offset points\", fontsize=9, color=INK_MUTED\n    )\n\n# Chrome\ntitle = \"Sensor Temperatures · ecdf-basic · python · matplotlib · anyplot.ai\"\ntitle_fs = max(8, round(12 * 67 / len(title))) if len(title) > 67 else 12\nax.set_title(title, fontsize=title_fs, fontweight=\"medium\", color=INK)\nax.set_xlabel(\"Temperature (°C)\", fontsize=10, color=INK)\nax.set_ylabel(\"Cumulative Proportion\", fontsize=10, color=INK)\nax.tick_params(axis=\"both\", labelsize=8, colors=INK_SOFT, labelcolor=INK_SOFT)\nax.set_ylim(0, 1.02)\nax.set_xlim(left=t_min - 0.5)\n\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\nax.yaxis.grid(True, alpha=0.15, linewidth=0.8, color=INK)\n\nfig.subplots_adjust(left=0.09, right=0.97, top=0.92, bottom=0.12)\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}