Skip to content

Commit a12fc07

Browse files
feat(pygal): implement scatter-categorical (#2615)
## Implementation: `scatter-categorical` - pygal Implements the **pygal** version of `scatter-categorical`. **File:** `plots/scatter-categorical/implementations/pygal.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594557818)* --------- 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 058b461 commit a12fc07

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+
scatter-categorical: Categorical Scatter Plot
3+
Library: pygal 3.1.0 | Python 3.13.11
4+
Quality: 92/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 - Iris-like flower measurements by species
13+
np.random.seed(42)
14+
15+
# Three species with different characteristic measurements
16+
species = ["Setosa", "Versicolor", "Virginica"]
17+
n_per_species = 40
18+
19+
# Setosa: small petals (low x, low y)
20+
setosa_x = np.random.normal(1.5, 0.25, n_per_species)
21+
setosa_y = np.random.normal(0.3, 0.1, n_per_species)
22+
23+
# Versicolor: medium petals (medium x, medium y)
24+
versicolor_x = np.random.normal(4.2, 0.6, n_per_species)
25+
versicolor_y = np.random.normal(1.3, 0.25, n_per_species)
26+
27+
# Virginica: large petals (high x, high y)
28+
virginica_x = np.random.normal(5.5, 0.6, n_per_species)
29+
virginica_y = np.random.normal(2.0, 0.3, n_per_species)
30+
31+
# Custom style for large canvas
32+
custom_style = Style(
33+
background="white",
34+
plot_background="white",
35+
foreground="#333333",
36+
foreground_strong="#333333",
37+
foreground_subtle="#666666",
38+
colors=("#306998", "#FFD43B", "#2ca02c"), # Python Blue, Python Yellow, Green
39+
title_font_size=56,
40+
label_font_size=40,
41+
major_label_font_size=36,
42+
legend_font_size=36,
43+
value_font_size=28,
44+
opacity=0.7,
45+
opacity_hover=0.9,
46+
stroke_width=0,
47+
dots_size=12,
48+
)
49+
50+
# Create XY scatter chart
51+
chart = pygal.XY(
52+
width=4800,
53+
height=2700,
54+
style=custom_style,
55+
title="scatter-categorical · pygal · pyplots.ai",
56+
x_title="Petal Length (cm)",
57+
y_title="Petal Width (cm)",
58+
show_x_guides=True,
59+
show_y_guides=True,
60+
legend_at_bottom=False,
61+
legend_box_size=24,
62+
truncate_legend=-1,
63+
dots_size=12,
64+
)
65+
66+
# Add data for each species as (x, y) tuples
67+
chart.add("Setosa", list(zip(setosa_x, setosa_y, strict=True)))
68+
chart.add("Versicolor", list(zip(versicolor_x, versicolor_y, strict=True)))
69+
chart.add("Virginica", list(zip(virginica_x, virginica_y, strict=True)))
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: scatter-categorical
3+
created: '2025-12-30T10:38:00Z'
4+
updated: '2025-12-30T10:45:27Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594557818
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/scatter-categorical/pygal/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-categorical/pygal/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/scatter-categorical/pygal/plot.html
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent use of Iris-like data providing a realistic, scientifically meaningful
17+
context
18+
- Clean three-cluster separation clearly demonstrates categorical grouping
19+
- Good color palette (Python colors) that is colorblind-safe
20+
- Proper use of pygal custom Style with appropriately scaled font sizes for 4800x2700
21+
canvas
22+
- Correct title format and descriptive axis labels with units
23+
- Alpha transparency (0.7) allows visibility of any overlapping points
24+
weaknesses:
25+
- Legend positioned in top-left overlaps with the plot area grid region; consider
26+
legend_at_bottom=True or repositioning
27+
- Marker stroke_width=0 removes outlines which could help distinguish overlapping
28+
points

0 commit comments

Comments
 (0)