Skip to content

Commit 058b461

Browse files
feat(plotly): implement line-styled (#2614)
## Implementation: `line-styled` - plotly Implements the **plotly** version of `line-styled`. **File:** `plots/line-styled/implementations/plotly.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594555333)* --------- 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 c0a82cf commit 058b461

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
""" pyplots.ai
2+
line-styled: Styled Line Plot
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 - Temperature readings from different sensors over 24 hours
12+
np.random.seed(42)
13+
hours = np.arange(0, 24)
14+
15+
# Simulate temperature patterns for different locations
16+
sensor_a = 15 + 8 * np.sin((hours - 6) * np.pi / 12) + np.random.normal(0, 0.5, 24) # Outdoor
17+
sensor_b = 20 + 3 * np.sin((hours - 8) * np.pi / 12) + np.random.normal(0, 0.3, 24) # Indoor
18+
sensor_c = 18 + 5 * np.sin((hours - 7) * np.pi / 12) + np.random.normal(0, 0.4, 24) # Greenhouse
19+
sensor_d = 22 + 2 * np.sin((hours - 10) * np.pi / 12) + np.random.normal(0, 0.2, 24) # Storage
20+
21+
# Create figure
22+
fig = go.Figure()
23+
24+
# Add traces with different line styles
25+
fig.add_trace(
26+
go.Scatter(
27+
x=hours, y=sensor_a, mode="lines", name="Outdoor Sensor", line=dict(dash="solid", width=4, color="#306998")
28+
)
29+
)
30+
31+
fig.add_trace(
32+
go.Scatter(
33+
x=hours, y=sensor_b, mode="lines", name="Indoor Sensor", line=dict(dash="dash", width=4, color="#FFD43B")
34+
)
35+
)
36+
37+
fig.add_trace(
38+
go.Scatter(
39+
x=hours, y=sensor_c, mode="lines", name="Greenhouse Sensor", line=dict(dash="dot", width=4, color="#4CAF50")
40+
)
41+
)
42+
43+
fig.add_trace(
44+
go.Scatter(
45+
x=hours, y=sensor_d, mode="lines", name="Storage Sensor", line=dict(dash="dashdot", width=4, color="#9C27B0")
46+
)
47+
)
48+
49+
# Update layout
50+
fig.update_layout(
51+
title=dict(text="line-styled · plotly · pyplots.ai", font=dict(size=32), x=0.5, xanchor="center"),
52+
xaxis=dict(
53+
title=dict(text="Hour of Day", font=dict(size=24)),
54+
tickfont=dict(size=20),
55+
tickmode="linear",
56+
tick0=0,
57+
dtick=4,
58+
gridcolor="rgba(0,0,0,0.1)",
59+
gridwidth=1,
60+
range=[-0.5, 23.5],
61+
),
62+
yaxis=dict(
63+
title=dict(text="Temperature (°C)", font=dict(size=24)),
64+
tickfont=dict(size=20),
65+
gridcolor="rgba(0,0,0,0.1)",
66+
gridwidth=1,
67+
),
68+
legend=dict(
69+
font=dict(size=20),
70+
x=0.02,
71+
y=0.98,
72+
xanchor="left",
73+
yanchor="top",
74+
bgcolor="rgba(255,255,255,0.8)",
75+
bordercolor="rgba(0,0,0,0.2)",
76+
borderwidth=1,
77+
),
78+
template="plotly_white",
79+
plot_bgcolor="white",
80+
paper_bgcolor="white",
81+
margin=dict(l=100, r=60, t=100, b=80),
82+
)
83+
84+
# Save as PNG (4800 x 2700 px)
85+
fig.write_image("plot.png", width=1600, height=900, scale=3)
86+
87+
# Save as HTML for interactivity
88+
fig.write_html("plot.html", include_plotlyjs="cdn")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library: plotly
2+
specification_id: line-styled
3+
created: '2025-12-30T10:37:58Z'
4+
updated: '2025-12-30T10:45:21Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594555333
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-styled/plotly/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-styled/plotly/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-styled/plotly/plot.html
13+
quality_score: 94
14+
review:
15+
strengths:
16+
- Excellent visual clarity with all four line styles (solid, dashed, dotted, dash-dot)
17+
easily distinguishable
18+
- Well-chosen realistic scenario with temperature sensors showing believable diurnal
19+
patterns
20+
- Proper use of Plotly layout customization for professional appearance
21+
- Good color palette with distinct, accessible colors
22+
- Appropriate line width (4) for the canvas size
23+
- Clean, simple code following KISS principles
24+
- Both PNG and HTML outputs generated for static and interactive use
25+
weaknesses:
26+
- Blue (#306998) and purple (#9C27B0) lines could be more differentiated for better
27+
colorblind accessibility
28+
- Could utilize Plotly-specific features like custom hover templates to enhance
29+
interactivity
30+
- Grid alpha at 0.1 is at the very low end of visibility

0 commit comments

Comments
 (0)