Skip to content

Commit 3d3a50c

Browse files
chore(altair): add metadata for facet-grid
1 parent 6f28863 commit 3d3a50c

2 files changed

Lines changed: 60 additions & 225 deletions

File tree

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
""" pyplots.ai
1+
"""anyplot.ai
22
facet-grid: Faceted Grid Plot
3-
Library: altair 6.0.0 | Python 3.13.11
4-
Quality: 91/100 | Created: 2025-12-30
3+
Library: altair | Python 3.13
4+
Quality: pending | Created: 2026-05-13
55
"""
66

7+
import os
8+
79
import altair as alt
810
import numpy as np
911
import pandas as pd
1012

1113

14+
# Theme tokens
15+
THEME = os.getenv("ANYPLOT_THEME", "light")
16+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
17+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
18+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
19+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
20+
21+
OKABE_ITO = ["#009E73", "#D55E00", "#0072B2", "#CC79A7", "#E69F00", "#56B4E9", "#F0E442"]
22+
1223
# Data - Crop yield across different soil types and seasons
1324
np.random.seed(42)
1425

@@ -21,11 +32,8 @@
2132
for soil in soil_types:
2233
for season in seasons:
2334
for crop in crop_types:
24-
# Base yield varies by soil type
2535
base_yield = {"Sandy": 3.5, "Clay": 4.0, "Loam": 5.0}[soil]
26-
# Season affects yield
2736
season_mult = {"Spring": 0.9, "Summer": 1.1, "Fall": 1.0}[season]
28-
# Crop type affects yield and water needs
2937
crop_base = {"Wheat": 3.8, "Corn": 4.5, "Soybean": 3.2}[crop]
3038

3139
yield_val = np.random.normal(base_yield * season_mult + crop_base, 0.8, n_per_group)
@@ -44,31 +52,49 @@
4452

4553
df = pd.DataFrame(data)
4654

47-
# Create faceted chart with scatter plots - facet by soil and season, color by crop
55+
# Create faceted chart with scatter plots
4856
chart = (
4957
alt.Chart(df)
50-
.mark_circle(size=100, opacity=0.7)
58+
.mark_circle(size=150, opacity=0.7)
5159
.encode(
5260
x=alt.X("Water Usage (mm):Q", scale=alt.Scale(zero=False)),
5361
y=alt.Y("Yield (tons/ha):Q", scale=alt.Scale(zero=False)),
54-
color=alt.Color("Crop:N", scale=alt.Scale(domain=crop_types, range=["#306998", "#FFD43B", "#4CAF50"])),
62+
color=alt.Color("Crop:N", scale=alt.Scale(domain=crop_types, range=OKABE_ITO[:3])),
5563
tooltip=["Yield (tons/ha)", "Water Usage (mm)", "Soil Type", "Season", "Crop"],
5664
)
5765
.properties(width=320, height=260)
5866
.facet(
5967
column=alt.Column(
60-
"Season:N", header=alt.Header(titleFontSize=20, labelFontSize=16), sort=["Spring", "Summer", "Fall"]
68+
"Season:N", header=alt.Header(titleFontSize=22, labelFontSize=18), sort=["Spring", "Summer", "Fall"]
6169
),
6270
row=alt.Row(
63-
"Soil Type:N", header=alt.Header(titleFontSize=20, labelFontSize=16), sort=["Sandy", "Clay", "Loam"]
71+
"Soil Type:N", header=alt.Header(titleFontSize=22, labelFontSize=18), sort=["Sandy", "Clay", "Loam"]
6472
),
6573
)
66-
.configure_axis(labelFontSize=14, titleFontSize=16)
67-
.configure_legend(titleFontSize=18, labelFontSize=16, symbolSize=180)
68-
.configure_title(fontSize=24)
69-
.properties(title="facet-grid · altair · pyplots.ai")
74+
.configure_axis(
75+
labelFontSize=16,
76+
titleFontSize=20,
77+
domainColor=INK_SOFT,
78+
tickColor=INK_SOFT,
79+
gridColor=INK,
80+
gridOpacity=0.10,
81+
labelColor=INK_SOFT,
82+
titleColor=INK,
83+
)
84+
.configure_legend(
85+
titleFontSize=18,
86+
labelFontSize=16,
87+
symbolSize=180,
88+
fillColor=ELEVATED_BG,
89+
strokeColor=INK_SOFT,
90+
labelColor=INK_SOFT,
91+
titleColor=INK,
92+
)
93+
.configure_title(fontSize=28, color=INK)
94+
.configure_view(fill=PAGE_BG, stroke=INK_SOFT)
95+
.properties(title="facet-grid · altair · anyplot.ai", background=PAGE_BG)
7096
)
7197

7298
# Save as PNG and HTML
73-
chart.save("plot.png", scale_factor=3.0)
74-
chart.save("plot.html")
99+
chart.save(f"plot-{THEME}.png", scale_factor=3.0)
100+
chart.save(f"plot-{THEME}.html")
Lines changed: 17 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,21 @@
1+
# Per-library metadata for altair implementation of facet-grid
2+
# Auto-generated by impl-generate.yml
3+
14
library: altair
5+
language: python
26
specification_id: facet-grid
37
created: '2025-12-30T16:30:41Z'
4-
updated: '2025-12-30T16:38:55Z'
5-
generated_by: claude-opus-4-5-20251101
6-
workflow_run: 20601059244
7-
issue: 0
8-
python_version: 3.13.11
9-
library_version: 6.0.0
10-
preview_url: https://storage.googleapis.com/anyplot-images/plots/facet-grid/altair/plot.png
11-
preview_html: https://storage.googleapis.com/anyplot-images/plots/facet-grid/altair/plot.html
12-
quality_score: 91
13-
impl_tags:
14-
dependencies: []
15-
techniques:
16-
- faceting
17-
- html-export
18-
patterns:
19-
- data-generation
20-
- iteration-over-groups
21-
dataprep: []
22-
styling: []
8+
updated: '2026-05-13T03:34:01Z'
9+
generated_by: claude-haiku
10+
workflow_run: 25776543142
11+
issue: 2696
12+
python_version: 3.13.13
13+
library_version: 6.1.0
14+
preview_url_light: https://storage.googleapis.com/anyplot-images/plots/facet-grid/python/altair/plot-light.png
15+
preview_url_dark: https://storage.googleapis.com/anyplot-images/plots/facet-grid/python/altair/plot-dark.png
16+
preview_html_light: https://storage.googleapis.com/anyplot-images/plots/facet-grid/python/altair/plot-light.html
17+
preview_html_dark: https://storage.googleapis.com/anyplot-images/plots/facet-grid/python/altair/plot-dark.html
18+
quality_score: null
2319
review:
24-
strengths:
25-
- Excellent use of Altair's declarative faceting syntax with .facet() for clean
26-
2D grid creation
27-
- Well-structured agricultural scenario that naturally demonstrates multi-dimensional
28-
data exploration
29-
- Clean color palette (blue, yellow, green) that is both aesthetically pleasing
30-
and colorblind-safe
31-
- Proper use of Altair encoding types (:Q for quantitative, :N for nominal)
32-
- Good axis labels with units and appropriate scale configuration
33-
weaknesses:
34-
- Legend is positioned at the edge of the canvas rather than integrated closer to
35-
the plot area
36-
- Could benefit from interactive selections (Altair's distinctive feature) to highlight
37-
crop types across all facets
38-
image_description: 'The plot displays a 3×3 faceted grid of scatter plots showing
39-
crop yield vs water usage. The grid is organized with Season (Spring, Summer,
40-
Fall) as columns and Soil Type (Sandy, Clay, Loam) as rows. Each subplot contains
41-
scatter points colored by crop type: blue for Wheat, yellow for Corn, and green
42-
for Soybean. The title "facet-grid · altair · pyplots.ai" appears at the top left.
43-
Axis labels show "Water Usage (mm)" on x-axis (range ~40-95) and "Yield (tons/ha)"
44-
on y-axis (range ~5-13). A color legend for Crop appears on the right side. The
45-
grid lines are subtle gray, and the overall layout is clean with good spacing
46-
between panels.'
47-
criteria_checklist:
48-
visual_quality:
49-
score: 36
50-
max: 40
51-
items:
52-
- id: VQ-01
53-
name: Text Legibility
54-
score: 9
55-
max: 10
56-
passed: true
57-
comment: All text is readable; title, axis labels, and tick marks are appropriately
58-
sized, though axis title font could be slightly larger
59-
- id: VQ-02
60-
name: No Overlap
61-
score: 8
62-
max: 8
63-
passed: true
64-
comment: No overlapping text anywhere in the visualization
65-
- id: VQ-03
66-
name: Element Visibility
67-
score: 7
68-
max: 8
69-
passed: true
70-
comment: Markers are well-sized with good opacity (0.7); slightly crowded
71-
in some cells but still distinguishable
72-
- id: VQ-04
73-
name: Color Accessibility
74-
score: 5
75-
max: 5
76-
passed: true
77-
comment: Blue, yellow, and green palette is colorblind-safe
78-
- id: VQ-05
79-
name: Layout Balance
80-
score: 4
81-
max: 5
82-
passed: true
83-
comment: Good use of canvas space; the faceted grid fills the area well, though
84-
legend is positioned slightly away from the main plot
85-
- id: VQ-06
86-
name: Axis Labels
87-
score: 2
88-
max: 2
89-
passed: true
90-
comment: 'Labels include units: "Yield (tons/ha)", "Water Usage (mm)"'
91-
- id: VQ-07
92-
name: Grid & Legend
93-
score: 1
94-
max: 2
95-
passed: true
96-
comment: Grid is subtle; legend is clear but positioned at the edge
97-
spec_compliance:
98-
score: 25
99-
max: 25
100-
items:
101-
- id: SC-01
102-
name: Plot Type
103-
score: 8
104-
max: 8
105-
passed: true
106-
comment: Correct faceted grid with scatter plots in each cell
107-
- id: SC-02
108-
name: Data Mapping
109-
score: 5
110-
max: 5
111-
passed: true
112-
comment: X (Water Usage) and Y (Yield) correctly assigned with two categorical
113-
faceting variables
114-
- id: SC-03
115-
name: Required Features
116-
score: 5
117-
max: 5
118-
passed: true
119-
comment: 'All spec features present: faceting by row (Soil Type) and column
120-
(Season), shared axes, scatter as base plot'
121-
- id: SC-04
122-
name: Data Range
123-
score: 3
124-
max: 3
125-
passed: true
126-
comment: All data visible within axes ranges
127-
- id: SC-05
128-
name: Legend Accuracy
129-
score: 2
130-
max: 2
131-
passed: true
132-
comment: Crop legend correctly shows all three categories
133-
- id: SC-06
134-
name: Title Format
135-
score: 2
136-
max: 2
137-
passed: true
138-
comment: Correct format "facet-grid · altair · pyplots.ai"
139-
data_quality:
140-
score: 18
141-
max: 20
142-
items:
143-
- id: DQ-01
144-
name: Feature Coverage
145-
score: 7
146-
max: 8
147-
passed: true
148-
comment: Shows variation across soil types (Loam yields higher), seasons (Summer
149-
slightly higher), and crops; demonstrates the multi-dimensional exploration
150-
purpose well
151-
- id: DQ-02
152-
name: Realistic Context
153-
score: 7
154-
max: 7
155-
passed: true
156-
comment: Crop yield vs water usage across soil types and seasons is a realistic
157-
agricultural scenario
158-
- id: DQ-03
159-
name: Appropriate Scale
160-
score: 4
161-
max: 5
162-
passed: true
163-
comment: Yield values (5-13 tons/ha) and water usage (40-95 mm) are plausible,
164-
though water usage range is on the lower end for seasonal measurements
165-
code_quality:
166-
score: 9
167-
max: 10
168-
items:
169-
- id: CQ-01
170-
name: KISS Structure
171-
score: 3
172-
max: 3
173-
passed: true
174-
comment: Clean imports → data → plot → save structure, no functions/classes
175-
- id: CQ-02
176-
name: Reproducibility
177-
score: 3
178-
max: 3
179-
passed: true
180-
comment: Uses np.random.seed(42)
181-
- id: CQ-03
182-
name: Clean Imports
183-
score: 2
184-
max: 2
185-
passed: true
186-
comment: All imports are used (altair, numpy, pandas)
187-
- id: CQ-04
188-
name: No Deprecated API
189-
score: 1
190-
max: 1
191-
passed: true
192-
comment: Current Altair API used
193-
- id: CQ-05
194-
name: Output Correct
195-
score: 0
196-
max: 1
197-
passed: false
198-
comment: Saves as both plot.png and plot.html, which is fine, but minor deduction
199-
for not following the exact single-output convention
200-
library_features:
201-
score: 3
202-
max: 5
203-
items:
204-
- id: LF-01
205-
name: Uses distinctive library features
206-
score: 3
207-
max: 5
208-
passed: true
209-
comment: Good use of Altair's declarative faceting with .facet(), Column/Row
210-
headers, encoding types (:Q, :N), and tooltips. Could leverage more Altair-specific
211-
features like interactive selections or conditional encoding
212-
verdict: APPROVED
20+
strengths: []
21+
weaknesses: []

0 commit comments

Comments
 (0)