Skip to content

Commit 3495112

Browse files
feat(letsplot): implement scatter-regression-lowess (#2873)
## Implementation: `scatter-regression-lowess` - letsplot Implements the **letsplot** version of `scatter-regression-lowess`. **File:** `plots/scatter-regression-lowess/implementations/letsplot.py` **Parent Issue:** #2855 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20608465143)* --------- 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 03fb48d commit 3495112

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
""" pyplots.ai
2+
scatter-regression-lowess: Scatter Plot with LOWESS Regression
3+
Library: letsplot 4.8.2 | Python 3.13.11
4+
Quality: 93/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import pandas as pd
9+
from lets_plot import (
10+
LetsPlot,
11+
aes,
12+
element_text,
13+
geom_point,
14+
geom_smooth,
15+
ggplot,
16+
ggsave,
17+
ggsize,
18+
labs,
19+
theme,
20+
theme_minimal,
21+
)
22+
23+
24+
LetsPlot.setup_html()
25+
26+
# Data - Complex non-linear relationship (plant growth vs temperature)
27+
np.random.seed(42)
28+
n = 200
29+
x = np.linspace(5, 40, n)
30+
# Growth peaks at moderate temps, drops at extremes
31+
y = 15 + 8 * np.sin((x - 5) * np.pi / 35) + 3 * np.cos((x - 10) * np.pi / 15) + np.random.randn(n) * 2.5
32+
33+
df = pd.DataFrame({"temperature": x, "growth_rate": y})
34+
35+
# Plot
36+
plot = (
37+
ggplot(df, aes(x="temperature", y="growth_rate"))
38+
+ geom_point(color="#306998", size=4, alpha=0.6)
39+
+ geom_smooth(method="loess", span=0.4, color="#FFD43B", size=2.5, se=True, fill="#FFD43B", alpha=0.2)
40+
+ labs(x="Temperature (°C)", y="Growth Rate (cm/day)", title="scatter-regression-lowess · letsplot · pyplots.ai")
41+
+ theme_minimal()
42+
+ theme(
43+
plot_title=element_text(size=24),
44+
axis_title=element_text(size=20),
45+
axis_text=element_text(size=16),
46+
legend_text=element_text(size=16),
47+
)
48+
+ ggsize(1600, 900)
49+
)
50+
51+
# Save PNG (scale 3x for 4800 x 2700 px)
52+
ggsave(plot, "plot.png", path=".", scale=3)
53+
54+
# Save HTML for interactive version
55+
ggsave(plot, "plot.html", path=".")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library: letsplot
2+
specification_id: scatter-regression-lowess
3+
created: '2025-12-30T23:53:52Z'
4+
updated: '2025-12-30T23:58:59Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20608465143
7+
issue: 2855
8+
python_version: 3.13.11
9+
library_version: 4.8.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/scatter-regression-lowess/letsplot/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-regression-lowess/letsplot/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/scatter-regression-lowess/letsplot/plot.html
13+
quality_score: 93
14+
review:
15+
strengths:
16+
- Excellent LOWESS implementation using geom_smooth with loess method and confidence
17+
band (se=True)
18+
- Perfect title format and descriptive axis labels with units
19+
- Realistic plant growth vs temperature scenario that naturally demonstrates LOWESS
20+
benefits
21+
- Good color contrast between blue points and yellow curve with appropriate transparency
22+
- Clean code structure following KISS principles with reproducible seed
23+
weaknesses:
24+
- Confidence band fill color (#FFD43B) same as line color - could use a lighter/different
25+
shade for better visual distinction
26+
- Some imports listed individually could be consolidated (minor style issue)

0 commit comments

Comments
 (0)