{"spec_id":"band-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nband-basic: Basic Band Plot\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-29\n\"\"\"\n\nimport os\nimport sys\n\n\n# Fix sys.path to avoid importing local matplotlib.py file\nif sys.path and sys.path[0] == os.path.dirname(os.path.abspath(__file__)):\n    sys.path.pop(0)\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\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\"\n\n# Imprint palette: first series #009E73 (band fill), position 3 #4467A3 (center line)\nBRAND = \"#009E73\"\nCONTRAST = \"#4467A3\"\n\n# Data: 7-day temperature forecast from 200-member ensemble weather model\nnp.random.seed(42)\nn_points = 80\nn_ensemble = 200\ndays = np.linspace(0, 7, n_points)\n\n# Base forecast: diurnal temperature cycle with gradual warming trend\nbase = 15 + 6 * np.sin(2 * np.pi * days - np.pi / 2) + 0.4 * days\n\n# Ensemble members diverge via cumulative random drift (uncertainty grows with horizon)\ndrifts = np.cumsum(np.random.normal(0, 0.08, (n_ensemble, n_points)), axis=1)\nall_temps = base + drifts\n\ndf = pd.DataFrame({\"Forecast Day\": np.tile(days, n_ensemble), \"Temperature (°C)\": all_temps.ravel()})\n\n# Scale context then apply theme-adaptive chrome\nsns.set_context(\"notebook\", font_scale=1.0)\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.15,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Canvas — 3200×1800 px (landscape 16:9); no bbox_inches='tight' per seaborn hard rule\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# sns.lineplot natively computes mean + 95% prediction interval from long-format ensemble\nsns.lineplot(\n    data=df,\n    x=\"Forecast Day\",\n    y=\"Temperature (°C)\",\n    estimator=\"mean\",\n    errorbar=(\"pi\", 95),\n    color=BRAND,\n    linewidth=2.5,\n    err_kws={\"alpha\": 0.25},\n    ax=ax,\n)\n\n# Contrasting center line (Imprint blue) for visual hierarchy; z-ordered above band\nax.lines[0].set_color(CONTRAST)\nax.lines[0].set_zorder(10)\n\nax.lines[0].set_label(\"Ensemble Mean\")\nax.collections[0].set_label(\"95% Prediction Interval\")\n\ntitle = \"band-basic · python · seaborn · anyplot.ai\"\nax.set_title(title, fontsize=12, fontweight=\"medium\", color=INK)\nax.set_xlabel(\"Forecast Horizon (days)\", fontsize=10, color=INK)\nax.set_ylabel(\"Temperature (°C)\", fontsize=10, color=INK)\nax.tick_params(axis=\"both\", labelsize=8)\n\nsns.despine(ax=ax)\nax.yaxis.grid(True, alpha=0.15, linewidth=0.6, color=INK)\n\nax.legend(fontsize=8, loc=\"upper left\", framealpha=0.9, facecolor=ELEVATED_BG, edgecolor=INK_SOFT)\n\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}