Skip to content

Commit 715e096

Browse files
feat(letsplot): implement line-styled (#2641)
## Implementation: `line-styled` - letsplot Implements the **letsplot** version of `line-styled`. **File:** `plots/line-styled/implementations/letsplot.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594564313)* --------- 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 b9d830d commit 715e096

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# ruff: noqa: F405
2+
"""pyplots.ai
3+
line-styled: Styled Line Plot
4+
Library: lets-plot | Python 3.13
5+
Quality: pending | Created: 2025-12-30
6+
"""
7+
8+
import numpy as np
9+
import pandas as pd
10+
from lets_plot import * # noqa: F403
11+
12+
13+
LetsPlot.setup_html()
14+
15+
# Data - Monthly temperature readings from different weather stations
16+
np.random.seed(42)
17+
months = np.arange(1, 13)
18+
month_names = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
19+
20+
# Temperature patterns for different climate zones
21+
base_temp = np.array([2, 4, 8, 12, 17, 21, 24, 23, 19, 13, 7, 3])
22+
coastal = base_temp + np.random.randn(12) * 0.5 + 3
23+
continental = base_temp + np.random.randn(12) * 0.8 - 2
24+
mountain = base_temp + np.random.randn(12) * 0.6 - 8
25+
mediterranean = base_temp + np.random.randn(12) * 0.4 + 5
26+
27+
# Create long-format DataFrame for lets-plot
28+
df = pd.DataFrame(
29+
{
30+
"Month": np.tile(months, 4),
31+
"Month_Name": np.tile(month_names, 4),
32+
"Temperature": np.concatenate([coastal, continental, mountain, mediterranean]),
33+
"Station": np.repeat(["Coastal", "Continental", "Mountain", "Mediterranean"], 12),
34+
}
35+
)
36+
37+
# Create plot with different line styles
38+
plot = (
39+
ggplot(df, aes(x="Month", y="Temperature", color="Station", linetype="Station"))
40+
+ geom_line(size=2.5)
41+
+ geom_point(size=5, alpha=0.8)
42+
+ scale_color_manual(values=["#306998", "#FFD43B", "#DC2626", "#22C55E"])
43+
+ scale_linetype_manual(values=["solid", "dashed", "dotted", "longdash"])
44+
+ scale_x_continuous(breaks=months.tolist(), labels=month_names)
45+
+ labs(
46+
x="Month",
47+
y="Temperature (°C)",
48+
title="line-styled · letsplot · pyplots.ai",
49+
color="Climate Zone",
50+
linetype="Climate Zone",
51+
)
52+
+ theme_minimal()
53+
+ theme(
54+
plot_title=element_text(size=28, face="bold"),
55+
axis_title=element_text(size=22),
56+
axis_text=element_text(size=18),
57+
legend_title=element_text(size=20),
58+
legend_text=element_text(size=18),
59+
legend_position="right",
60+
panel_grid_major=element_line(color="#CCCCCC", size=0.5),
61+
panel_grid_minor=element_line(color="#DDDDDD", size=0.3),
62+
)
63+
+ ggsize(1600, 900)
64+
)
65+
66+
# Save as PNG (scale 3x = 4800 × 2700 px)
67+
ggsave(plot, "plot.png", path=".", scale=3)
68+
69+
# Save as HTML for interactive viewing
70+
ggsave(plot, "plot.html", path=".")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
library: letsplot
2+
specification_id: line-styled
3+
created: '2025-12-30T10:44:00Z'
4+
updated: '2025-12-30T10:56:50Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594564313
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 4.8.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-styled/letsplot/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-styled/letsplot/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/line-styled/letsplot/plot.html
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent use of all four standard line styles (solid, dashed, dotted, longdash)
17+
as specified
18+
- Perfect title format following the {spec-id} · {library} · pyplots.ai convention
19+
- 'Strong accessibility: combining color AND line style ensures print/colorblind
20+
friendliness'
21+
- Clean, readable code following KISS principles with proper seed for reproducibility
22+
- Realistic climate zone temperature data that makes intuitive sense
23+
- Well-sized text elements (28pt title, 22pt labels, 18pt ticks) appropriate for
24+
4800×2700 output
25+
weaknesses:
26+
- Legend in code specifies color=Climate Zone and linetype=Climate Zone but the
27+
data column is Station - while it works, the column naming is inconsistent
28+
- All four climate zones follow the same basic seasonal pattern (low in winter,
29+
high in summer) - could show more variation (e.g., Southern Hemisphere climate
30+
with inverse pattern)

0 commit comments

Comments
 (0)