Skip to content

Commit bb4931f

Browse files
feat(plotnine): implement line-markers (#2608)
## Implementation: `line-markers` - plotnine Implements the **plotnine** version of `line-markers`. **File:** `plots/line-markers/implementations/plotnine.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594558022)* --------- 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 9229ffd commit bb4931f

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
""" pyplots.ai
2+
line-markers: Line Plot with Markers
3+
Library: plotnine 0.15.2 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-30
5+
"""
6+
7+
import numpy as np
8+
import pandas as pd
9+
from plotnine import (
10+
aes,
11+
element_text,
12+
geom_line,
13+
geom_point,
14+
ggplot,
15+
labs,
16+
scale_color_manual,
17+
scale_shape_manual,
18+
theme,
19+
theme_minimal,
20+
)
21+
22+
23+
# Data: Monthly temperature readings from two weather stations
24+
np.random.seed(42)
25+
months = np.arange(1, 13)
26+
month_labels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
27+
28+
# Station A: Coastal location (milder temperatures)
29+
station_a = np.array([8, 9, 12, 15, 19, 23, 26, 26, 22, 17, 12, 9]) + np.random.randn(12) * 0.5
30+
31+
# Station B: Inland location (more extreme temperatures)
32+
station_b = np.array([2, 4, 10, 16, 21, 26, 29, 28, 22, 14, 7, 3]) + np.random.randn(12) * 0.5
33+
34+
df = pd.DataFrame(
35+
{
36+
"Month": month_labels * 2,
37+
"Month_Num": list(months) * 2,
38+
"Temperature": np.concatenate([station_a, station_b]),
39+
"Station": ["Coastal Station"] * 12 + ["Inland Station"] * 12,
40+
}
41+
)
42+
43+
# Plot
44+
plot = (
45+
ggplot(df, aes(x="Month_Num", y="Temperature", color="Station", shape="Station"))
46+
+ geom_line(size=1.5, alpha=0.8)
47+
+ geom_point(size=5, alpha=0.9)
48+
+ scale_color_manual(values=["#306998", "#FFD43B"])
49+
+ scale_shape_manual(values=["o", "s"])
50+
+ labs(
51+
x="Month",
52+
y="Temperature (°C)",
53+
title="line-markers · plotnine · pyplots.ai",
54+
color="Weather Station",
55+
shape="Weather Station",
56+
)
57+
+ theme_minimal()
58+
+ theme(
59+
figure_size=(16, 9),
60+
text=element_text(size=14),
61+
axis_title=element_text(size=20),
62+
axis_text=element_text(size=16),
63+
plot_title=element_text(size=24),
64+
legend_text=element_text(size=16),
65+
legend_title=element_text(size=18),
66+
legend_position="right",
67+
)
68+
)
69+
70+
plot.save("plot.png", dpi=300, verbose=False)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library: plotnine
2+
specification_id: line-markers
3+
created: '2025-12-30T10:37:30Z'
4+
updated: '2025-12-30T10:43:01Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594558022
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 0.15.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/line-markers/plotnine/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/line-markers/plotnine/plot_thumb.png
12+
preview_html: null
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent use of plotnine grammar of graphics with proper aesthetic mappings for
17+
color and shape
18+
- 'Well-chosen colorblind-safe color palette (blue #306998 and yellow #FFD43B)'
19+
- Realistic and meaningful data scenario comparing coastal vs inland temperature
20+
patterns
21+
- Proper marker and line sizing for visibility at the target resolution
22+
- Clean readable code following KISS principles
23+
weaknesses:
24+
- X-axis displays numeric month values (1, 2.5, 5, 7.5, 10, 12.5) instead of month
25+
names (Jan, Feb, etc.) - the month_labels were created but not used on the axis

0 commit comments

Comments
 (0)