Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 18 additions & 11 deletions plots/density-basic/implementations/plotnine.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
""" pyplots.ai
density-basic: Basic Density Plot
Library: plotnine 0.15.2 | Python 3.13.11
Quality: 91/100 | Created: 2025-12-23
Library: plotnine 0.15.3 | Python 3.14
Quality: /100 | Updated: 2026-02-23

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation header docstring has an incomplete quality field (Quality: /100), which breaks the standard header format and may break tooling that parses the score. Populate the numeric quality value (and keep the NN/100 format consistent with other plot implementations).

Suggested change
Quality: /100 | Updated: 2026-02-23
Quality: 92/100 | Updated: 2026-02-23

Copilot uses AI. Check for mistakes.
"""

import numpy as np
import pandas as pd
from plotnine import (
aes,
after_stat,
coord_cartesian,
element_blank,
element_line,
element_text,
geom_density,
geom_area,
geom_line,
geom_rug,
ggplot,
labs,
scale_x_continuous,
scale_y_continuous,
theme,
theme_minimal,
)
Expand All @@ -29,27 +33,30 @@
np.random.normal(88, 5, 50), # High achievers
]
)
test_scores = np.clip(test_scores, 0, 100) # Scores between 0-100
test_scores = np.clip(test_scores, 0, 100)

df = pd.DataFrame({"score": test_scores})

# Plot with bandwidth adjustment for smoother curve
# Plot - layered density using stat_density for filled area + outline
plot = (
ggplot(df, aes(x="score"))
+ geom_density(fill="#306998", color="#306998", alpha=0.6, size=1.5, bw="scott")
+ geom_rug(color="#FFD43B", alpha=0.7, size=1)
+ geom_area(aes(y=after_stat("density")), stat="density", fill="#306998", alpha=0.5, color="none")
+ geom_line(aes(y=after_stat("density")), stat="density", color="#1a3d5c", size=1.8)
+ geom_rug(color="#306998", alpha=0.4, size=0.8)
+ labs(x="Test Score (points)", y="Probability Density", title="density-basic · plotnine · pyplots.ai")
+ scale_x_continuous(limits=(30, 100), breaks=range(30, 101, 10))
+ coord_cartesian(xlim=(30, 100))
+ scale_x_continuous(breaks=range(40, 101, 10))
+ scale_y_continuous(expand=(0, 0, 0.05, 0))
+ coord_cartesian(xlim=(40, 102))
+ theme_minimal()
+ theme(
figure_size=(16, 9),
text=element_text(size=14),
axis_title=element_text(size=20),
axis_text=element_text(size=16),
plot_title=element_text(size=24),
panel_grid_major=element_line(color="#cccccc", alpha=0.3),
panel_grid_minor=element_line(color="#eeeeee", alpha=0.2),
panel_grid_major_x=element_blank(),
panel_grid_minor=element_blank(),
panel_grid_major_y=element_line(color="#cccccc", alpha=0.2, size=0.5),
)
)

Expand Down
18 changes: 9 additions & 9 deletions plots/density-basic/metadata/plotnine.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
library: plotnine
specification_id: density-basic
created: '2025-12-23T10:00:30Z'
updated: '2025-12-23T10:04:55Z'
generated_by: claude-opus-4-5-20251101
updated: '2026-02-23T22:38:00+00:00'
generated_by: claude-opus-4-6
workflow_run: 20457535942
issue: 0
python_version: 3.13.11
library_version: 0.15.2
python_version: 3.14.3
library_version: 0.15.3
preview_url: https://storage.googleapis.com/pyplots-images/plots/density-basic/plotnine/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/density-basic/plotnine/plot_thumb.png
preview_html: null
quality_score: 91
quality_score: null

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quality_score is set to null, but other plot metadata files use an integer score (and the PR description references a score). This will likely break any consumers expecting a numeric quality value; set it to the actual quality score for this implementation.

Suggested change
quality_score: null
quality_score: 92

Copilot uses AI. Check for mistakes.
impl_tags:
dependencies: []
techniques:
- layer-composition
- layer-composition
patterns:
- data-generation
- data-generation
dataprep:
- kde
- kde
styling:
- alpha-blending
- alpha-blending
review:
strengths:
- Clean plotnine grammar of graphics implementation using geom_density with appropriate
Expand Down
Loading