{"spec_id":"line-timeseries","library":"plotly","language":"python","code":"\"\"\" anyplot.ai\nline-timeseries: Time Series Line Plot\nLibrary: plotly 6.7.0 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-09\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport pandas as pd\nimport plotly.graph_objects as go\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\"\nGRID = \"rgba(26,26,23,0.10)\" if THEME == \"light\" else \"rgba(240,239,232,0.10)\"\nBRAND = \"#009E73\"  # Okabe-Ito position 1\n\n# Data - Stock prices with uptrend\nnp.random.seed(42)\ndates = pd.date_range(start=\"2024-01-01\", end=\"2024-12-31\", freq=\"D\")\ndays = np.arange(len(dates))\ntrend = 100 + 0.15 * days\nvolatility = 5 * np.sin(2 * np.pi * days / 60)\nnoise = np.random.randn(len(dates)) * 2\nprices = trend + volatility + noise\n\ndf = pd.DataFrame({\"date\": dates, \"price\": prices})\n\n# Create plot\nfig = go.Figure()\n\nfig.add_trace(\n    go.Scatter(\n        x=df[\"date\"],\n        y=df[\"price\"],\n        mode=\"lines\",\n        line={\"color\": BRAND, \"width\": 3},\n        name=\"Stock Price\",\n        hovertemplate=\"Date: %{x|%b %d, %Y}<br>Price: $%{y:.2f}<extra></extra>\",\n    )\n)\n\n# Layout for 4800x2700 px\nfig.update_layout(\n    title={\n        \"text\": \"line-timeseries · plotly · anyplot.ai\",\n        \"font\": {\"size\": 28, \"color\": INK},\n        \"x\": 0.5,\n        \"xanchor\": \"center\",\n    },\n    xaxis={\n        \"title\": {\"text\": \"Date\", \"font\": {\"size\": 22, \"color\": INK}},\n        \"tickfont\": {\"size\": 18, \"color\": INK_SOFT},\n        \"tickformat\": \"%b %Y\",\n        \"dtick\": \"M1\",\n        \"gridcolor\": GRID,\n        \"gridwidth\": 1,\n        \"showgrid\": True,\n        \"linecolor\": INK_SOFT,\n        \"zerolinecolor\": INK_SOFT,\n        \"rangeslider\": {\"visible\": True, \"thickness\": 0.05},\n    },\n    yaxis={\n        \"title\": {\"text\": \"Stock Price ($)\", \"font\": {\"size\": 22, \"color\": INK}},\n        \"tickfont\": {\"size\": 18, \"color\": INK_SOFT},\n        \"gridcolor\": GRID,\n        \"gridwidth\": 1,\n        \"showgrid\": True,\n        \"linecolor\": INK_SOFT,\n        \"zerolinecolor\": INK_SOFT,\n    },\n    paper_bgcolor=PAGE_BG,\n    plot_bgcolor=PAGE_BG,\n    font={\"color\": INK},\n    margin={\"l\": 100, \"r\": 80, \"t\": 120, \"b\": 100},\n    showlegend=False,\n    hovermode=\"x unified\",\n)\n\n# Save as PNG (4800x2700 px) and HTML\nfig.write_image(f\"plot-{THEME}.png\", width=1600, height=900, scale=3)\nfig.write_html(f\"plot-{THEME}.html\", include_plotlyjs=\"cdn\")\n"}