Skip to content

Commit 4c8c7fa

Browse files
feat(pygal): implement line-styled (#2612)
## Implementation: `line-styled` - pygal Implements the **pygal** version of `line-styled`. **File:** `plots/line-styled/implementations/pygal.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594559510)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 5c2d990 commit 4c8c7fa

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
""" pyplots.ai
2+
line-styled: Styled Line Plot
3+
Library: pygal 3.1.0 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import pygal
9+
from pygal.style import Style
10+
11+
12+
# Data - Temperature measurements from 4 different sensors over 12 months
13+
np.random.seed(42)
14+
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
15+
base_temp = np.array([5, 7, 12, 16, 20, 24, 26, 25, 21, 15, 9, 6])
16+
17+
sensor_a = base_temp + np.random.randn(12) * 1.5
18+
sensor_b = base_temp + 3 + np.random.randn(12) * 1.5
19+
sensor_c = base_temp - 2 + np.random.randn(12) * 1.5
20+
sensor_d = base_temp + 1.5 + np.random.randn(12) * 1.5
21+
22+
# Custom style for large canvas (4800x2700)
23+
custom_style = Style(
24+
background="white",
25+
plot_background="white",
26+
foreground="#333333",
27+
foreground_strong="#333333",
28+
foreground_subtle="#666666",
29+
colors=("#306998", "#FFD43B", "#E74C3C", "#2ECC71"),
30+
title_font_size=72,
31+
label_font_size=48,
32+
major_label_font_size=42,
33+
legend_font_size=42,
34+
value_font_size=36,
35+
tooltip_font_size=36,
36+
stroke_width=6,
37+
font_family="DejaVu Sans",
38+
)
39+
40+
# Create line chart with different stroke styles
41+
chart = pygal.Line(
42+
width=4800,
43+
height=2700,
44+
style=custom_style,
45+
title="line-styled · pygal · pyplots.ai",
46+
x_title="Month",
47+
y_title="Temperature (°C)",
48+
show_x_guides=False,
49+
show_y_guides=True,
50+
legend_at_bottom=False,
51+
legend_box_size=30,
52+
dots_size=8,
53+
stroke_style={"width": 6},
54+
show_dots=True,
55+
truncate_legend=-1,
56+
margin=50,
57+
margin_top=120,
58+
margin_bottom=100,
59+
)
60+
61+
# Set x-axis labels
62+
chart.x_labels = months
63+
64+
# Add series with different stroke dash arrays for line styles
65+
# Pygal uses stroke_dasharray for line styles
66+
chart.add("Sensor A (Solid)", sensor_a.tolist(), stroke_style={"width": 6, "dasharray": "0"})
67+
chart.add("Sensor B (Dashed)", sensor_b.tolist(), stroke_style={"width": 6, "dasharray": "30, 15"})
68+
chart.add("Sensor C (Dotted)", sensor_c.tolist(), stroke_style={"width": 6, "dasharray": "8, 12"})
69+
chart.add("Sensor D (Dash-Dot)", sensor_d.tolist(), stroke_style={"width": 6, "dasharray": "30, 10, 8, 10"})
70+
71+
# Save as PNG and HTML
72+
chart.render_to_png("plot.png")
73+
chart.render_to_file("plot.html")
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
library: pygal
2+
specification_id: line-styled
3+
created: '2025-12-30T10:37:51Z'
4+
updated: '2025-12-30T10:44:40Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594559510
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 3.1.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-styled/pygal/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-styled/pygal/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-styled/pygal/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent implementation of all 4 standard line styles (solid, dashed, dotted,
17+
dash-dot) using pygal stroke_dasharray
18+
- Clear, readable text with appropriate font sizes for the large canvas
19+
- Realistic temperature sensor data scenario with seasonal variation
20+
- Clean code structure following KISS principles
21+
- Proper use of custom Style for large canvas sizing
22+
- Both PNG and interactive HTML outputs generated
23+
weaknesses:
24+
- Legend placement in upper left could be moved to avoid any potential overlap with
25+
data
26+
- Color palette includes red-green combination; while line styles provide differentiation,
27+
a more colorblind-friendly palette would be better
28+
- Could showcase more pygal-specific features like tooltips or value labels

0 commit comments

Comments
 (0)