{"spec_id":"line-styled","library":"plotly","language":"python","code":"\"\"\" anyplot.ai\nline-styled: Styled Line Plot\nLibrary: plotly 6.7.0 | Python 3.13.13\nQuality: 85/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\n\nimport numpy as np\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.15)\" if THEME == \"light\" else \"rgba(240,239,232,0.15)\"\n\n# Okabe-Ito colors (position 1 is always brand green)\nIMPRINT = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\"]\n\n# Data - Temperature readings from different environments over 24 hours\nnp.random.seed(42)\nhours = np.arange(0, 24)\n\n# Simulate temperature patterns for different locations\nsensor_a = 15 + 8 * np.sin((hours - 6) * np.pi / 12) + np.random.normal(0, 0.5, 24)\nsensor_b = 20 + 3 * np.sin((hours - 8) * np.pi / 12) + np.random.normal(0, 0.3, 24)\nsensor_c = 18 + 5 * np.sin((hours - 7) * np.pi / 12) + np.random.normal(0, 0.4, 24)\nsensor_d = 22 + 2 * np.sin((hours - 10) * np.pi / 12) + np.random.normal(0, 0.2, 24)\n\n# Create figure\nfig = go.Figure()\n\n# Add traces with different line styles and Okabe-Ito colors\nfig.add_trace(\n    go.Scatter(\n        x=hours,\n        y=sensor_a,\n        mode=\"lines\",\n        name=\"Outdoor Sensor\",\n        line=dict(dash=\"solid\", width=4, color=IMPRINT[0]),\n        hovertemplate=\"<b>Outdoor</b><br>Hour: %{x}<br>Temp: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\nfig.add_trace(\n    go.Scatter(\n        x=hours,\n        y=sensor_b,\n        mode=\"lines\",\n        name=\"Indoor Sensor\",\n        line=dict(dash=\"dash\", width=4, color=IMPRINT[1]),\n        hovertemplate=\"<b>Indoor</b><br>Hour: %{x}<br>Temp: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\nfig.add_trace(\n    go.Scatter(\n        x=hours,\n        y=sensor_c,\n        mode=\"lines\",\n        name=\"Greenhouse Sensor\",\n        line=dict(dash=\"dot\", width=4, color=IMPRINT[2]),\n        hovertemplate=\"<b>Greenhouse</b><br>Hour: %{x}<br>Temp: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\nfig.add_trace(\n    go.Scatter(\n        x=hours,\n        y=sensor_d,\n        mode=\"lines\",\n        name=\"Storage Sensor\",\n        line=dict(dash=\"dashdot\", width=4, color=IMPRINT[3]),\n        hovertemplate=\"<b>Storage</b><br>Hour: %{x}<br>Temp: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\n# Update layout with theme-adaptive styling\nfig.update_layout(\n    title=dict(text=\"line-styled · plotly · anyplot.ai\", font=dict(size=28, color=INK), x=0.5, xanchor=\"center\"),\n    xaxis=dict(\n        title=dict(text=\"Hour of Day\", font=dict(size=22, color=INK)),\n        tickfont=dict(size=18, color=INK_SOFT),\n        tickmode=\"linear\",\n        tick0=0,\n        dtick=4,\n        gridcolor=GRID,\n        gridwidth=1,\n        linecolor=INK_SOFT,\n        range=[-0.5, 23.5],\n    ),\n    yaxis=dict(\n        title=dict(text=\"Temperature (°C)\", font=dict(size=22, color=INK)),\n        tickfont=dict(size=18, color=INK_SOFT),\n        gridcolor=GRID,\n        gridwidth=1,\n        linecolor=INK_SOFT,\n    ),\n    legend=dict(\n        font=dict(size=18, color=INK_SOFT),\n        x=0.02,\n        y=0.98,\n        xanchor=\"left\",\n        yanchor=\"top\",\n        bgcolor=ELEVATED_BG,\n        bordercolor=INK_SOFT,\n        borderwidth=1,\n    ),\n    paper_bgcolor=PAGE_BG,\n    plot_bgcolor=PAGE_BG,\n    margin=dict(l=100, r=60, t=100, b=80),\n    hovermode=\"x unified\",\n)\n\n# Save as PNG 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"}