{"spec_id":"line-timeseries","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nline-timeseries: Time Series Line Plot\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 88/100 | Updated: 2026-05-09\n\"\"\"\n\nimport os\n\nimport matplotlib.dates as mdates\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\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# Theme-adaptive seaborn configuration\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# Data: Daily temperature readings over 3 months\nnp.random.seed(42)\ndates = pd.date_range(start=\"2024-01-01\", periods=90, freq=\"D\")\n\nday_of_year = np.arange(90)\nbase_temp = 5 + 10 * np.sin(2 * np.pi * (day_of_year + 10) / 365)\nnoise = np.random.randn(90) * 3\ntemperature = base_temp + noise\n\ndf = pd.DataFrame({\"Date\": dates, \"Temperature (°C)\": temperature})\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\n\nsns.lineplot(data=df, x=\"Date\", y=\"Temperature (°C)\", color=BRAND, linewidth=3, ax=ax, errorbar=(\"ci\", 95))\n\n# Style\nax.set_xlabel(\"Date\", fontsize=20, color=INK)\nax.set_ylabel(\"Temperature (°C)\", fontsize=20, color=INK)\nax.set_title(\"line-timeseries · seaborn · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Smart date formatting\nax.xaxis.set_major_locator(mdates.MonthLocator())\nax.xaxis.set_major_formatter(mdates.DateFormatter(\"%b %Y\"))\nax.xaxis.set_minor_locator(mdates.WeekdayLocator(byweekday=mdates.MO))\n\n# Rotate labels to prevent overlap\nplt.setp(ax.get_xticklabels(), rotation=45, ha=\"right\")\n\n# Grid on both axes for readability\nax.grid(True, alpha=0.15, linewidth=0.8, color=INK)\n\n# Remove top and right spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor spine in [\"left\", \"bottom\"]:\n    ax.spines[spine].set_color(INK_SOFT)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}