Skip to content

Commit 079e040

Browse files
feat(plotly): implement line-markers (#2620)
## Implementation: `line-markers` - plotly Implements the **plotly** version of `line-markers`. **File:** `plots/line-markers/implementations/plotly.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594556252)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e762f62 commit 079e040

2 files changed

Lines changed: 119 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
""" pyplots.ai
2+
line-markers: Line Plot with Markers
3+
Library: plotly 6.5.0 | Python 3.13.11
4+
Quality: 94/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import plotly.graph_objects as go
9+
10+
11+
# Data - experimental temperature readings over time
12+
np.random.seed(42)
13+
x = np.arange(0, 15)
14+
15+
# Three sensor series with different patterns
16+
sensor_a = 20 + np.cumsum(np.random.randn(15) * 0.8)
17+
sensor_b = 22 + np.cumsum(np.random.randn(15) * 0.6) - 2
18+
sensor_c = 18 + np.cumsum(np.random.randn(15) * 1.0) + 1
19+
20+
# Create figure
21+
fig = go.Figure()
22+
23+
# Add traces with different marker styles
24+
fig.add_trace(
25+
go.Scatter(
26+
x=x,
27+
y=sensor_a,
28+
mode="lines+markers",
29+
name="Sensor A",
30+
line=dict(color="#306998", width=4),
31+
marker=dict(size=16, symbol="circle", color="#306998", line=dict(width=2, color="white")),
32+
)
33+
)
34+
35+
fig.add_trace(
36+
go.Scatter(
37+
x=x,
38+
y=sensor_b,
39+
mode="lines+markers",
40+
name="Sensor B",
41+
line=dict(color="#FFD43B", width=4),
42+
marker=dict(size=16, symbol="square", color="#FFD43B", line=dict(width=2, color="#333333")),
43+
)
44+
)
45+
46+
fig.add_trace(
47+
go.Scatter(
48+
x=x,
49+
y=sensor_c,
50+
mode="lines+markers",
51+
name="Sensor C",
52+
line=dict(color="#E55934", width=4),
53+
marker=dict(size=16, symbol="diamond", color="#E55934", line=dict(width=2, color="white")),
54+
)
55+
)
56+
57+
# Layout
58+
fig.update_layout(
59+
title=dict(text="line-markers · plotly · pyplots.ai", font=dict(size=32), x=0.5, xanchor="center"),
60+
xaxis=dict(
61+
title=dict(text="Time (hours)", font=dict(size=24)),
62+
tickfont=dict(size=20),
63+
showgrid=True,
64+
gridwidth=1,
65+
gridcolor="rgba(0,0,0,0.1)",
66+
dtick=2,
67+
),
68+
yaxis=dict(
69+
title=dict(text="Temperature (°C)", font=dict(size=24)),
70+
tickfont=dict(size=20),
71+
showgrid=True,
72+
gridwidth=1,
73+
gridcolor="rgba(0,0,0,0.1)",
74+
),
75+
legend=dict(
76+
font=dict(size=20),
77+
x=0.02,
78+
y=0.98,
79+
xanchor="left",
80+
yanchor="top",
81+
bgcolor="rgba(255,255,255,0.8)",
82+
bordercolor="rgba(0,0,0,0.2)",
83+
borderwidth=1,
84+
),
85+
template="plotly_white",
86+
margin=dict(l=100, r=60, t=100, b=80),
87+
plot_bgcolor="white",
88+
)
89+
90+
# Save as PNG and HTML
91+
fig.write_image("plot.png", width=1600, height=900, scale=3)
92+
fig.write_html("plot.html", include_plotlyjs=True, full_html=True)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library: plotly
2+
specification_id: line-markers
3+
created: '2025-12-30T10:38:15Z'
4+
updated: '2025-12-30T10:46:24Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594556252
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 6.5.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-markers/plotly/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-markers/plotly/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-markers/plotly/plot.html
13+
quality_score: 94
14+
review:
15+
strengths:
16+
- Excellent marker visibility with distinct shapes (circle, square, diamond) for
17+
each series
18+
- White border lines on markers provide excellent contrast against the lines
19+
- Clean, professional layout with appropriate font sizes for high-resolution output
20+
- Good use of Plotly graph_objects for fine-grained control over styling
21+
- Outputs both PNG and interactive HTML, showcasing Plotly dual capability
22+
- Realistic temperature sensor scenario that fits the sparse data use case well
23+
weaknesses:
24+
- Legend could be positioned outside the plot area (e.g., to the right) to avoid
25+
any potential overlap with data
26+
- Hover templates or other interactive features could better showcase Plotly distinctive
27+
capabilities

0 commit comments

Comments
 (0)