Skip to content

Commit 8baebfb

Browse files
feat(letsplot): implement scatter-basic (#1326)
## Implementation: `scatter-basic` - letsplot Implements the **letsplot** version of `scatter-basic`. **File:** `plots/scatter-basic/implementations/letsplot.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20446960716)* --------- 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 af28f52 commit 8baebfb

2 files changed

Lines changed: 36 additions & 21 deletions

File tree

plots/scatter-basic/implementations/letsplot.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" pyplots.ai
22
scatter-basic: Basic Scatter Plot
3-
Library: letsplot 4.8.1 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-13
3+
Library: letsplot unknown | Python 3.13.11
4+
Quality: 90/100 | Created: 2025-12-22
55
"""
66

77
import numpy as np
@@ -12,20 +12,27 @@
1212

1313
LetsPlot.setup_html() # noqa: F405
1414

15-
# Data
15+
# Data - Simulating study hours vs exam scores relationship
1616
np.random.seed(42)
17-
n = 150
18-
x = np.random.randn(n) * 2 + 10
19-
y = x * 0.8 + np.random.randn(n) * 2
17+
n = 120
18+
study_hours = np.random.uniform(1, 10, n)
19+
exam_scores = study_hours * 8 + 20 + np.random.randn(n) * 5
2020

21-
df = pd.DataFrame({"x": x, "y": y})
21+
df = pd.DataFrame({"study_hours": study_hours, "exam_scores": exam_scores})
2222

23-
# Plot
23+
# Plot with interactive tooltips
2424
plot = (
25-
ggplot(df, aes(x="x", y="y")) # noqa: F405
26-
+ geom_point(color="#306998", size=5, alpha=0.7) # noqa: F405
25+
ggplot(df, aes(x="study_hours", y="exam_scores")) # noqa: F405
26+
+ geom_point( # noqa: F405
27+
color="#306998",
28+
size=6,
29+
alpha=0.7,
30+
tooltips=layer_tooltips() # noqa: F405
31+
.line("Study Hours|@study_hours")
32+
.line("Exam Score|@exam_scores"),
33+
)
2734
+ labs( # noqa: F405
28-
x="X Value", y="Y Value", title="scatter-basic · lets-plot · pyplots.ai"
35+
x="Study Hours (hrs)", y="Exam Score (points)", title="scatter-basic · letsplot · pyplots.ai"
2936
)
3037
+ ggsize(1600, 900) # noqa: F405
3138
+ theme_minimal() # noqa: F405
@@ -37,7 +44,7 @@
3744
)
3845
)
3946

40-
# Save PNG (scale 3x to get 4800 × 2700 px)
47+
# Save PNG (scale 3x to get 4800 x 2700 px)
4148
export_ggsave(plot, filename="plot.png", path=".", scale=3)
4249

4350
# Save HTML for interactive version
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
library: letsplot
22
specification_id: scatter-basic
3-
created: 2025-12-13 23:13:54+00:00
4-
updated: 2025-12-13 23:13:54+00:00
3+
created: '2025-12-22T23:43:07Z'
4+
updated: '2025-12-23T00:06:42Z'
55
generated_by: claude-opus-4-5-20251101
6-
workflow_run: 20199223509
7-
issue: 611
6+
workflow_run: 20446960716
7+
issue: 0
88
python_version: 3.13.11
9-
library_version: 4.8.1
9+
library_version: unknown
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/scatter-basic/letsplot/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-basic/letsplot/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/scatter-basic/letsplot/plot.html
13-
quality_score: 92
13+
quality_score: 90
1414
review:
15-
strengths: []
16-
weaknesses: []
17-
improvements: []
15+
strengths:
16+
- Clean ggplot2-style grammar of graphics implementation
17+
- Proper use of theme_minimal() with customized text sizes for readability
18+
- Correct 16:9 aspect ratio with 3x scale export for high-resolution output
19+
- Exports both PNG and interactive HTML versions
20+
- Good transparency (alpha=0.7) for revealing overlapping points
21+
- Subtle dashed grid lines that do not overwhelm the data
22+
weaknesses:
23+
- Data labels use generic X Value/Y Value instead of a realistic scenario (e.g.,
24+
Study Hours vs Exam Score)
25+
- Title text could be slightly larger for better visibility at full resolution

0 commit comments

Comments
 (0)