Skip to content

Commit 4cdfd61

Browse files
update(arc-basic): pygal — comprehensive quality review
Comprehensive review and update of pygal implementation for arc-basic.
1 parent b1e8c8c commit 4cdfd61

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

plots/arc-basic/implementations/pygal.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
arc-basic: Basic Arc Diagram
3-
Library: pygal 3.1.0 | Python 3.13.11
4-
Quality: 94/100 | Created: 2025-12-17
3+
Library: pygal 3.1.0 | Python 3.14.3
4+
Quality: /100 | Updated: 2026-02-23
55
"""
66

77
import math
@@ -39,13 +39,16 @@
3939

4040
# Node positions along x-axis (1 to 10 range)
4141
x_positions = np.linspace(1, 10, n_nodes)
42-
y_baseline = 1.0
42+
y_baseline = 0.5
4343

44-
# Build color tuple: Python Blue for all arcs, Python Yellow for nodes
44+
# Color palette: weight-based blue shades for arcs (lighter=weak, darker=strong)
45+
arc_blues = {1: "#7BA7C9", 2: "#306998", 3: "#1B3F5C"}
46+
47+
# Build colors tuple: one entry per edge series + node series
4548
n_edges = len(edges)
46-
colors = tuple(["#306998"] * n_edges + ["#FFD43B"])
49+
colors = tuple([arc_blues[w] for _, _, w in edges] + ["#FFD43B"])
4750

48-
# Custom style for the chart
51+
# Custom style
4952
custom_style = Style(
5053
background="white",
5154
plot_background="white",
@@ -59,7 +62,7 @@
5962
legend_font_size=40,
6063
value_font_size=32,
6164
stroke_width=3,
62-
opacity=0.65,
65+
opacity=0.7,
6366
opacity_hover=1.0,
6467
)
6568

@@ -79,16 +82,14 @@
7982
stroke=True,
8083
dots_size=0,
8184
stroke_style={"width": 3, "linecap": "round"},
82-
range=(0, 6),
85+
range=(0, 4.6),
8386
xrange=(0, 11),
84-
x_labels=nodes,
85-
x_labels_major_count=n_nodes,
87+
x_labels=[{"value": float(x_positions[i]), "label": nodes[i]} for i in range(n_nodes)],
8688
truncate_label=-1,
8789
)
8890

8991
# Generate arc points for each edge
90-
# Each arc is drawn as a series of points forming a semi-circle
91-
arc_resolution = 30 # Number of points per arc
92+
arc_resolution = 40
9293

9394
for start_idx, end_idx, weight in edges:
9495
x_start = x_positions[start_idx]
@@ -98,19 +99,18 @@
9899
x_center = (x_start + x_end) / 2
99100
arc_radius = abs(x_end - x_start) / 2
100101

101-
# Arc height proportional to the distance between nodes
102+
# Arc height proportional to node distance
102103
distance = abs(end_idx - start_idx)
103104
height_scale = 0.4 * distance
104105

105106
# Generate arc points (semi-circle above baseline)
106107
arc_points = []
107108
for i in range(arc_resolution + 1):
108-
theta = math.pi * i / arc_resolution # 0 to pi
109+
theta = math.pi * i / arc_resolution
109110
x = x_center - arc_radius * math.cos(theta)
110111
y = y_baseline + height_scale * math.sin(theta)
111112
arc_points.append((x, y))
112113

113-
# Line thickness based on weight
114114
chart.add(
115115
f"Arc {start_idx}-{end_idx}",
116116
arc_points,
@@ -120,19 +120,15 @@
120120
stroke_style={"width": 2 + weight * 2, "linecap": "round"},
121121
)
122122

123-
# Add nodes as a separate series (last, so uses Python Yellow)
124-
node_points = []
125-
for i, name in enumerate(nodes):
126-
x = x_positions[i]
127-
node_points.append({"value": (x, y_baseline), "label": name})
128-
123+
# Add nodes as a separate series (last, uses Python Yellow)
124+
node_points = [{"value": (float(x_positions[i]), y_baseline), "label": nodes[i]} for i in range(n_nodes)]
129125
chart.add("Characters", node_points, stroke=False, dots_size=35)
130126

131127
# Save outputs
132128
chart.render_to_file("plot.svg")
133129
chart.render_to_png("plot.png")
134130

135-
# Also save HTML for interactive version
131+
# Save HTML for interactive version
136132
with open("plot.html", "w") as f:
137133
f.write(
138134
"""<!DOCTYPE html>

plots/arc-basic/metadata/pygal.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: pygal
22
specification_id: arc-basic
33
created: 2025-12-17 10:58:08+00:00
4-
updated: 2025-12-17 10:58:08+00:00
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-23T12:00:00+00:00'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20300358253
77
issue: 991
8-
python_version: 3.13.11
8+
python_version: '3.14.3'
99
library_version: 3.1.0
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/arc-basic/pygal/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/arc-basic/pygal/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/arc-basic/pygal/plot.html
13-
quality_score: 94
13+
quality_score: null
1414
impl_tags:
1515
dependencies: []
1616
techniques:

0 commit comments

Comments
 (0)