{"spec_id":"area-basic","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\narea-basic: Basic Area Chart\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-28\n\"\"\"\n\nimport os\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\"\nBRAND = \"#009E73\"  # Imprint palette position 1 — ALWAYS first series\n\n# Data - daily website visitors over a month with weekend dips and a viral spike\nnp.random.seed(42)\ndays = np.arange(1, 31)\nbase_visitors = 3000 + np.linspace(0, 2000, 30)  # Upward trend 3k→5k\nweekend_effect = np.array([-1200 if d % 7 in (0, 6) else 0 for d in days])\nnoise = np.random.randn(30) * 300\nvisitors = base_visitors + weekend_effect + noise\nvisitors[17] = 8200  # Viral blog post spike on day 18\nvisitors[18] = 6800\nvisitors = np.clip(visitors, 1000, 10000)\n\n# Title with fontsize scaled to length\ntitle = \"Website Traffic · area-basic · python · matplotlib · anyplot.ai\"\nn = len(title)\ntitle_fontsize = max(8, round(12 * 67 / n)) if n > 67 else 12\n\n# Plot\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\ny_max = visitors.max() * 1.06\n\nax.fill_between(days, visitors, alpha=0.35, color=BRAND, zorder=2)\nax.plot(days, visitors, color=BRAND, linewidth=2.5, zorder=3)\n\n# Viral post annotation — to the right of the spike to avoid ceiling crowding\nax.annotate(\n    \"Viral post\",\n    xy=(18, visitors[17]),\n    xytext=(22, 6600),\n    fontsize=8,\n    color=INK,\n    fontweight=\"bold\",\n    arrowprops={\"arrowstyle\": \"->\", \"color\": INK_SOFT, \"lw\": 1.5},\n    zorder=4,\n)\n\n# Style\nax.set_xlabel(\"Day of Month\", fontsize=10, color=INK)\nax.set_ylabel(\"Daily Visitors\", fontsize=10, color=INK)\nax.set_title(title, fontsize=title_fontsize, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=8, colors=INK_SOFT)\nax.set_xlim(1, 30)\nax.set_ylim(0, y_max)\nax.yaxis.grid(True, alpha=0.15, linewidth=0.8, color=INK)\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\nfig.subplots_adjust(left=0.10, right=0.96, top=0.92, bottom=0.12)\n\n# Save\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}