Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions plots/scatter-regression-lowess/implementations/letsplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
""" pyplots.ai
scatter-regression-lowess: Scatter Plot with LOWESS Regression
Library: letsplot 4.8.2 | Python 3.13.11
Quality: 93/100 | Created: 2025-12-30
"""

import numpy as np
import pandas as pd
from lets_plot import (
LetsPlot,
aes,
element_text,
geom_point,
geom_smooth,
ggplot,
ggsave,
ggsize,
labs,
theme,
theme_minimal,
)


LetsPlot.setup_html()

# Data - Complex non-linear relationship (plant growth vs temperature)
np.random.seed(42)
n = 200
x = np.linspace(5, 40, n)
# Growth peaks at moderate temps, drops at extremes
y = 15 + 8 * np.sin((x - 5) * np.pi / 35) + 3 * np.cos((x - 10) * np.pi / 15) + np.random.randn(n) * 2.5

df = pd.DataFrame({"temperature": x, "growth_rate": y})

# Plot
plot = (
ggplot(df, aes(x="temperature", y="growth_rate"))
+ geom_point(color="#306998", size=4, alpha=0.6)
+ geom_smooth(method="loess", span=0.4, color="#FFD43B", size=2.5, se=True, fill="#FFD43B", alpha=0.2)
+ labs(x="Temperature (°C)", y="Growth Rate (cm/day)", title="scatter-regression-lowess · letsplot · pyplots.ai")
+ theme_minimal()
+ theme(
plot_title=element_text(size=24),
axis_title=element_text(size=20),
axis_text=element_text(size=16),
legend_text=element_text(size=16),
)
+ ggsize(1600, 900)
)

# Save PNG (scale 3x for 4800 x 2700 px)
ggsave(plot, "plot.png", path=".", scale=3)

# Save HTML for interactive version
ggsave(plot, "plot.html", path=".")
26 changes: 26 additions & 0 deletions plots/scatter-regression-lowess/metadata/letsplot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
library: letsplot
specification_id: scatter-regression-lowess
created: '2025-12-30T23:53:52Z'
updated: '2025-12-30T23:58:59Z'
generated_by: claude-opus-4-5-20251101
workflow_run: 20608465143
issue: 2855
python_version: 3.13.11
library_version: 4.8.2
preview_url: https://storage.googleapis.com/pyplots-images/plots/scatter-regression-lowess/letsplot/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-regression-lowess/letsplot/plot_thumb.png
preview_html: https://storage.googleapis.com/pyplots-images/plots/scatter-regression-lowess/letsplot/plot.html
quality_score: 93
review:
strengths:
- Excellent LOWESS implementation using geom_smooth with loess method and confidence
band (se=True)
- Perfect title format and descriptive axis labels with units
- Realistic plant growth vs temperature scenario that naturally demonstrates LOWESS
benefits
- Good color contrast between blue points and yellow curve with appropriate transparency
- Clean code structure following KISS principles with reproducible seed
weaknesses:
- Confidence band fill color (#FFD43B) same as line color - could use a lighter/different
shade for better visual distinction
- Some imports listed individually could be consolidated (minor style issue)