{"spec_id":"line-confidence","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nline-confidence: Line Plot with Confidence Interval\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 93/100 | Updated: 2026-05-09\n\"\"\"\n\nimport sys\n\n\nsys.path.pop(0)\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\n# Theme-adaptive colors\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# Data - Simulated temperature forecast with 95% confidence interval\nnp.random.seed(42)\ndays = np.arange(1, 31)  # 30 days forecast\n\n# Central forecast (mean temperature with slight trend)\nbase_temp = 15 + 0.3 * days + 3 * np.sin(days / 5)\ny = base_temp + np.random.randn(30) * 0.5\n\n# Confidence interval widens over time (typical for forecasts)\nuncertainty = 1.5 + 0.15 * days\ny_lower = y - uncertainty\ny_upper = y + uncertainty\n\n# Create plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Shaded confidence band (contrasting color with semi-transparent alpha)\n# Use sky blue (#2ABCCD) for the band to contrast with green line\nax.fill_between(days, y_lower, y_upper, alpha=0.25, color=\"#2ABCCD\", label=\"95% Confidence Interval\")\n\n# Central trend line (prominent, brand green)\nax.plot(days, y, color=\"#009E73\", linewidth=3, label=\"Forecast Mean\")\n\n# Styling\nax.set_xlabel(\"Days Ahead\", fontsize=20, color=INK)\nax.set_ylabel(\"Temperature (°C)\", fontsize=20, color=INK)\nax.set_title(\"Temperature Forecast with 95% Confidence Interval\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT, labelcolor=INK_SOFT)\n\n# Spine styling\nfor spine in [\"top\", \"right\"]:\n    ax.spines[spine].set_visible(False)\nfor spine in [\"left\", \"bottom\"]:\n    ax.spines[spine].set_color(INK_SOFT)\n    ax.spines[spine].set_linewidth(0.8)\n\n# Grid (subtle, y-axis only)\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(0.8)\n    for text in leg.get_texts():\n        text.set_color(INK_SOFT)\n\n# Set axis limits for clean display\nax.set_xlim(1, 30)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}