{"spec_id":"line-timeseries","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nline-timeseries: Time Series Line Plot\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 92/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\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 — ALWAYS first series\n\n# Data - Daily temperature readings over one year\nnp.random.seed(42)\ndates = pd.date_range(start=\"2024-01-01\", end=\"2024-12-31\", freq=\"D\")\n\n# Simulate realistic temperature pattern with seasonal variation\nday_of_year = np.arange(len(dates))\nseasonal = 15 * np.sin(2 * np.pi * (day_of_year - 80) / 365)\nbaseline = 12\nnoise = np.random.randn(len(dates)) * 3\ntemperature = baseline + seasonal + noise\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Time series line with brand color\nax.plot(dates, temperature, linewidth=3.0, color=BRAND, alpha=0.9)\n\n# Smart date formatting based on time range\nax.xaxis.set_major_locator(mdates.MonthLocator())\nax.xaxis.set_major_formatter(mdates.DateFormatter(\"%b %Y\"))\nax.xaxis.set_minor_locator(mdates.MonthLocator(bymonthday=15))\n\n# Rotate labels to prevent overlap\nplt.setp(ax.xaxis.get_majorticklabels(), rotation=45, ha=\"right\")\n\n# Labels and styling\nax.set_xlabel(\"Date\", fontsize=20, color=INK)\nax.set_ylabel(\"Temperature (°C)\", fontsize=20, color=INK)\nax.set_title(\n    \"Daily Temperature 2024 · line-timeseries · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK\n)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Spines\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\n# Grid for readability\nax.grid(True, alpha=0.10, which=\"major\", color=INK)\nax.grid(True, alpha=0.05, which=\"minor\", color=INK)\n\n# Set axis limits with padding\nax.set_xlim(dates[0], dates[-1])\nax.margins(y=0.05)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}