{"spec_id":"line-markers","library":"plotly","language":"python","code":"\"\"\" anyplot.ai\nline-markers: Line Plot with Markers\nLibrary: plotly 6.7.0 | Python 3.13.13\nQuality: 91/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport plotly.graph_objects as go\n\n\n# Theme-adaptive chrome\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)\"\n\n# Okabe-Ito palette\nBRAND = \"#009E73\"\nCOLOR_2 = \"#C475FD\"\nCOLOR_3 = \"#4467A3\"\n\n# Data - experimental temperature readings over time\nnp.random.seed(42)\nx = np.arange(0, 15)\n\n# Three sensor series with different patterns\nsensor_a = 20 + np.cumsum(np.random.randn(15) * 0.8)\nsensor_b = 22 + np.cumsum(np.random.randn(15) * 0.6) - 2\nsensor_c = 18 + np.cumsum(np.random.randn(15) * 1.0) + 1\n\n# Create figure\nfig = go.Figure()\n\n# Add traces with different marker styles\nfig.add_trace(\n    go.Scatter(\n        x=x,\n        y=sensor_a,\n        mode=\"lines+markers\",\n        name=\"Sensor A\",\n        line=dict(color=BRAND, width=4),\n        marker=dict(size=16, symbol=\"circle\", color=BRAND, line=dict(width=2, color=PAGE_BG)),\n        hovertemplate=\"<b>Sensor A</b><br>Time: %{x}h<br>Temperature: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\nfig.add_trace(\n    go.Scatter(\n        x=x,\n        y=sensor_b,\n        mode=\"lines+markers\",\n        name=\"Sensor B\",\n        line=dict(color=COLOR_2, width=4),\n        marker=dict(size=16, symbol=\"square\", color=COLOR_2, line=dict(width=2, color=PAGE_BG)),\n        hovertemplate=\"<b>Sensor B</b><br>Time: %{x}h<br>Temperature: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\nfig.add_trace(\n    go.Scatter(\n        x=x,\n        y=sensor_c,\n        mode=\"lines+markers\",\n        name=\"Sensor C\",\n        line=dict(color=COLOR_3, width=4),\n        marker=dict(size=16, symbol=\"diamond\", color=COLOR_3, line=dict(width=2, color=PAGE_BG)),\n        hovertemplate=\"<b>Sensor C</b><br>Time: %{x}h<br>Temperature: %{y:.1f}°C<extra></extra>\",\n    )\n)\n\n# Layout with theme-adaptive styling\nfig.update_layout(\n    title=dict(text=\"line-markers · plotly · anyplot.ai\", font=dict(size=28, color=INK), x=0.5, xanchor=\"center\"),\n    xaxis=dict(\n        title=dict(text=\"Time (hours)\", font=dict(size=22, color=INK)),\n        tickfont=dict(size=18, color=INK_SOFT),\n        showgrid=True,\n        gridwidth=1,\n        gridcolor=GRID,\n        dtick=2,\n        linecolor=INK_SOFT,\n        zerolinecolor=INK_SOFT,\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        showgrid=True,\n        gridwidth=1,\n        gridcolor=GRID,\n        linecolor=INK_SOFT,\n        zerolinecolor=INK_SOFT,\n    ),\n    legend=dict(\n        font=dict(size=16, color=INK_SOFT),\n        x=1.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    font=dict(color=INK),\n    margin=dict(l=100, r=160, t=100, b=80),\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"}