{"spec_id":"ecdf-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\necdf-basic: Basic ECDF Plot\nLibrary: seaborn 0.13.2 | Python 3.13.14\nQuality: 90/100 | Updated: 2026-06-25\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n\n# Theme tokens — Imprint palette + theme-adaptive chrome\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\"\n\n# Imprint categorical palette — positions 1, 2, 3 (Adelie, Chinstrap, Gentoo)\nIMPRINT_PALETTE = [\"#009E73\", \"#C475FD\", \"#4467A3\"]\n\nsns.set_theme(\n    style=\"ticks\",\n    rc={\n        \"figure.facecolor\": PAGE_BG,\n        \"axes.facecolor\": PAGE_BG,\n        \"axes.edgecolor\": INK_SOFT,\n        \"axes.labelcolor\": INK,\n        \"text.color\": INK,\n        \"xtick.color\": INK_SOFT,\n        \"ytick.color\": INK_SOFT,\n        \"grid.color\": INK,\n        \"grid.alpha\": 0.12,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Data — penguin flipper lengths by species (deterministic real-world dataset)\npenguins = sns.load_dataset(\"penguins\").dropna(subset=[\"flipper_length_mm\", \"species\"])\n\n# Plot — multi-hue ecdfplot shows distribution comparison across species\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\nsns.ecdfplot(data=penguins, x=\"flipper_length_mm\", hue=\"species\", palette=IMPRINT_PALETTE, linewidth=2.5, ax=ax)\n\n# Percentile reference lines for direct reading of Q1 / median / Q3\nfor p in (0.25, 0.50, 0.75):\n    ax.axhline(p, color=INK_MUTED, linewidth=0.7, linestyle=\"--\", alpha=0.55, zorder=0)\n\n# Style\ntitle = \"Penguin Flipper Lengths · ecdf-basic · python · seaborn · anyplot.ai\"\nn = len(title)\ntitle_fontsize = round(12 * 67 / n) if n > 67 else 12\nax.set_title(title, fontsize=title_fontsize, fontweight=\"medium\", color=INK)\nax.set_xlabel(\"Flipper Length (mm)\", fontsize=10, color=INK)\nax.set_ylabel(\"Cumulative Proportion\", fontsize=10, color=INK)\nax.tick_params(axis=\"both\", labelsize=8, colors=INK_SOFT)\nax.set_ylim(0, 1)\nax.set_yticks([0, 0.25, 0.50, 0.75, 1.0])\n\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor side in (\"left\", \"bottom\"):\n    ax.spines[side].set_color(INK_SOFT)\n\nax.yaxis.grid(True, alpha=0.12, linewidth=0.8, color=INK)\nax.set_axisbelow(True)\n\n# Style the auto-generated legend\nlegend = ax.get_legend()\nif legend:\n    legend.get_frame().set_facecolor(ELEVATED_BG)\n    legend.get_frame().set_edgecolor(INK_SOFT)\n    for text in legend.get_texts():\n        text.set_color(INK_SOFT)\n        text.set_fontsize(8)\n    legend.set_title(\"Species\", prop={\"size\": 8, \"weight\": \"medium\"})\n    legend.get_title().set_color(INK_SOFT)\n\n# Save — bbox_inches must stay default (None) to preserve exact figsize × dpi canvas\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}