{"spec_id":"line-confidence","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nline-confidence: Line Plot with Confidence Interval\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 92/100 | Updated: 2026-05-09\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\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\"  # Okabe-Ito position 1\n\n# Set theme for seaborn\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.10,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Data - Daily temperature forecast with growing confidence interval\nnp.random.seed(42)\n\n# Generate daily forecast for 30 days\ndays = np.arange(1, 31)\n\n# Create a realistic temperature trend with daily variation\nbase_temp = 18 + days * 0.3  # Warming trend\ndaily_cycle = 3 * np.sin(2 * np.pi * days / 7)  # Weekly pattern\nnoise = np.random.randn(len(days)) * 1.5\n\n# Central forecast\ny_forecast = base_temp + daily_cycle + noise\n\n# Confidence interval - widens as forecast horizon extends\nuncertainty = 1.5 + days * 0.15  # Growing uncertainty\ny_lower = y_forecast - 1.96 * uncertainty\ny_upper = y_forecast + 1.96 * uncertainty\n\n# Create plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\n\n# Plot confidence band using fill_between\nax.fill_between(days, y_lower, y_upper, alpha=0.25, color=BRAND, label=\"95% Confidence Interval\")\n\n# Plot central line\nax.plot(days, y_forecast, color=BRAND, linewidth=3, label=\"Forecast\", marker=\"o\", markersize=5)\n\n# Style\nax.set_xlabel(\"Day\", fontsize=20, color=INK)\nax.set_ylabel(\"Temperature (°C)\", fontsize=20, color=INK)\nax.set_title(\n    \"Temperature Forecast · line-confidence · seaborn · anyplot.ai\", fontsize=24, color=INK, fontweight=\"medium\"\n)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Remove top and right spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nax.spines[\"left\"].set_color(INK_SOFT)\nax.spines[\"bottom\"].set_color(INK_SOFT)\n\n# Grid\nax.yaxis.grid(True, alpha=0.10, linewidth=0.8, linestyle=\"-\")\n\n# Legend - position to avoid overlap with data\nax.legend(fontsize=16, loc=\"lower right\", framealpha=0.95)\n\n# Set axis limits with padding\nax.set_xlim(0, 31)\nax.set_ylim(min(y_lower) - 2, max(y_upper) + 2)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}