Skip to content

Commit 761f982

Browse files
update(area-basic): plotly — comprehensive quality review (#4173)
## Summary Updated **plotly** implementation for **area-basic**. ### Changes - Added spline line interpolation for smoother curves - Added rich hover template with formatted dates/numbers - Annotated peak traffic day with bordered label - Added range slider for interactive exploration in HTML - Added weekly x-axis ticks, comma-formatted y-axis ## Test Plan - [x] Preview images uploaded to GCS staging - [x] Implementation file passes ruff format/check - [x] Metadata YAML updated with current versions - [ ] Automated review triggered --- Generated with [Claude Code](https://claude.com/claude-code) `/update` command --------- 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 2f1b501 commit 761f982

2 files changed

Lines changed: 109 additions & 76 deletions

File tree

plots/area-basic/implementations/plotly.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" pyplots.ai
22
area-basic: Basic Area Chart
3-
Library: plotly 6.5.0 | Python 3.13.11
3+
Library: plotly 6.5.2 | Python 3.14.2
44
Quality: 92/100 | Created: 2025-12-23
55
"""
66

@@ -19,7 +19,7 @@
1919
weekly_pattern = 1000 * np.sin(np.arange(30) * 2 * np.pi / 7)
2020
noise = np.random.randn(30) * 500
2121
visitors = base + trend + weekly_pattern + noise
22-
visitors = np.maximum(visitors, 2000) # Ensure no negative values
22+
visitors = np.maximum(visitors, 2000).astype(int)
2323

2424
# Create figure
2525
fig = go.Figure()
@@ -30,13 +30,32 @@
3030
y=visitors,
3131
mode="lines",
3232
fill="tozeroy",
33-
fillcolor="rgba(48, 105, 152, 0.4)",
34-
line={"color": "#306998", "width": 3},
33+
fillcolor="rgba(48, 105, 152, 0.35)",
34+
line={"color": "#306998", "width": 3, "shape": "spline"},
3535
name="Daily Visitors",
36+
hovertemplate="<b>%{x|%b %d, %Y}</b><br>Visitors: %{y:,}<extra></extra>",
3637
)
3738
)
3839

39-
# Layout with proper sizing for 4800x2700 px
40+
# Annotate peak traffic day
41+
peak_idx = int(np.argmax(visitors))
42+
fig.add_annotation(
43+
x=dates[peak_idx],
44+
y=visitors[peak_idx],
45+
text=f"Peak: {visitors[peak_idx]:,}",
46+
showarrow=True,
47+
arrowhead=2,
48+
arrowsize=1.5,
49+
ax=0,
50+
ay=-40,
51+
font={"size": 16, "color": "#306998"},
52+
bordercolor="#306998",
53+
borderwidth=1.5,
54+
borderpad=4,
55+
bgcolor="rgba(255, 255, 255, 0.85)",
56+
)
57+
58+
# Layout
4059
fig.update_layout(
4160
title={
4261
"text": "Daily Website Visitors · area-basic · plotly · pyplots.ai",
@@ -45,26 +64,31 @@
4564
"xanchor": "center",
4665
},
4766
xaxis={
48-
"title": {"text": "Date", "font": {"size": 22}},
67+
"title": {"text": "Date (January 2024)", "font": {"size": 22}},
4968
"tickfont": {"size": 18},
5069
"showgrid": True,
5170
"gridwidth": 1,
52-
"gridcolor": "rgba(0, 0, 0, 0.1)",
71+
"gridcolor": "rgba(0, 0, 0, 0.15)",
72+
"dtick": 7 * 24 * 60 * 60 * 1000,
73+
"tickformat": "%b %d",
5374
},
5475
yaxis={
5576
"title": {"text": "Visitors (daily count)", "font": {"size": 22}},
5677
"tickfont": {"size": 18},
5778
"showgrid": True,
5879
"gridwidth": 1,
59-
"gridcolor": "rgba(0, 0, 0, 0.1)",
80+
"gridcolor": "rgba(0, 0, 0, 0.15)",
81+
"tickformat": ",",
6082
},
6183
template="plotly_white",
6284
showlegend=False,
6385
margin={"l": 80, "r": 40, "t": 80, "b": 60},
86+
hovermode="x unified",
6487
)
6588

6689
# Save as PNG (4800x2700 px)
6790
fig.write_image("plot.png", width=1600, height=900, scale=3)
6891

69-
# Save interactive HTML
92+
# Save interactive HTML with range slider for exploration
93+
fig.update_layout(xaxis_rangeslider_visible=True)
7094
fig.write_html("plot.html")
Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
11
library: plotly
22
specification_id: area-basic
33
created: '2025-12-23T00:46:42Z'
4-
updated: '2025-12-23T00:50:26Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-11T22:26:40Z'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20447954578
77
issue: 0
8-
python_version: 3.13.11
9-
library_version: 6.5.0
8+
python_version: 3.14.2
9+
library_version: 6.5.2
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/area-basic/plotly/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-basic/plotly/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/area-basic/plotly/plot.html
1313
quality_score: 92
1414
impl_tags:
1515
dependencies: []
16-
techniques: []
16+
techniques:
17+
- annotations
18+
- hover-tooltips
19+
- html-export
1720
patterns:
18-
- data-generation
19-
dataprep: []
21+
- data-generation
22+
dataprep:
23+
- time-series
2024
styling:
21-
- alpha-blending
25+
- alpha-blending
26+
- grid-styling
2227
review:
2328
strengths:
24-
- Excellent title format following the exact spec-id · library · pyplots.ai convention
25-
- Clean, realistic data simulation with weekly patterns and upward trend demonstrating
26-
area chart utility
27-
- Proper semi-transparent fill (alpha 0.4) as recommended in spec
28-
- Good font sizing following the library guidelines (28pt title, 22pt labels, 18pt
29-
ticks)
30-
- Correct output dimensions (4800x2700 via 1600x900 scale=3)
31-
- HTML output also generated for interactive viewing
29+
- Excellent data generation with realistic weekly traffic patterns and upward trend
30+
using sinusoidal component
31+
- Clean, professional visual design with well-chosen blue color from the pyplots
32+
palette
33+
- Peak annotation adds analytical value and showcases Plotly annotation capabilities
34+
- Proper font sizing throughout (28/22/18pt) following library guidelines exactly
35+
- Semi-transparent fill at 0.35 alpha balances readability and visual weight perfectly
36+
- Interactive HTML export with range slider demonstrates Plotly interactivity strengths
3237
weaknesses:
33-
- X-axis label could be more descriptive (e.g., "Date (January 2024)" instead of
34-
just "Date")
35-
- Missing hover template customization which is a key Plotly strength
36-
- Could benefit from range slider or zoom capabilities to showcase Plotly interactivity
37-
image_description: The plot displays a basic area chart showing daily website visitors
38-
over January 2024 (30 days). The x-axis shows dates from Jan 2, 2024 to Jan 29,
39-
2024, and the y-axis shows "Visitors (daily count)" ranging from 0 to approximately
40-
7000. The area below the line is filled with a semi-transparent blue color (rgba
41-
blue, ~0.4 alpha), while the line itself is a darker blue (#306998). The data
42-
exhibits a clear weekly cyclical pattern (peaks and troughs repeating roughly
43-
every 7 days) along with an overall upward trend from ~5000 to ~7000 visitors.
44-
The title "Daily Website Visitors · area-basic · plotly · pyplots.ai" is centered
45-
at the top. The background uses the plotly_white template with subtle light gray
46-
gridlines. The layout is clean with good margins and no overlapping elements.
38+
- No legend displayed — even for a single series, a small legend would improve chart
39+
completeness
40+
- Only 30 data points is at the low end of the spec range; denser data would better
41+
showcase the area chart strengths
42+
- Library features underutilized — could leverage Plotly-specific features like
43+
fill gradient pattern, range selector buttons, or spike lines for the static output
44+
image_description: 'The plot displays a basic area chart showing daily website visitors
45+
across January 2024. A smooth spline line in dark blue (#306998) traces the data
46+
with a semi-transparent blue fill (alpha ~0.35) extending down to the x-axis.
47+
The x-axis is labeled "Date (January 2024)" with weekly tick marks at Jan 07,
48+
Jan 14, Jan 21, and Jan 28. The y-axis is labeled "Visitors (daily count)" with
49+
comma-formatted ticks from 0 to 7,000+. The title "Daily Website Visitors · area-basic
50+
· plotly · pyplots.ai" is centered at the top. A bordered annotation "Peak: 7,135"
51+
with an arrow points to the highest data point near Jan 29. The background uses
52+
plotly_white template with subtle gray gridlines. The data shows a clear weekly
53+
cyclical pattern (dips roughly every 7 days) with an overall upward trend. Layout
54+
is balanced with good margins and no overlapping elements.'
4755
criteria_checklist:
4856
visual_quality:
4957
score: 37
@@ -54,47 +62,47 @@ review:
5462
score: 10
5563
max: 10
5664
passed: true
57-
comment: Title at 28pt, axis titles at 22pt, tick labels at 18pt - all perfectly
58-
readable
65+
comment: Title at 28pt, axis labels at 22pt, tick labels at 18pt all clearly
66+
readable at 4800x2700
5967
- id: VQ-02
6068
name: No Overlap
6169
score: 8
6270
max: 8
6371
passed: true
64-
comment: No overlapping text anywhere, dates are well-spaced
72+
comment: No overlapping text elements; annotation well-placed away from line
6573
- id: VQ-03
6674
name: Element Visibility
6775
score: 8
6876
max: 8
6977
passed: true
70-
comment: Line width of 3 is appropriate, area fill clearly visible with good
71-
alpha
78+
comment: Line width 3 well-suited; spline smoothing makes 30-point series
79+
clear; fill area visible
7280
- id: VQ-04
7381
name: Color Accessibility
7482
score: 5
7583
max: 5
7684
passed: true
77-
comment: Single blue color scheme, no colorblind concerns
85+
comment: Single-series blue chart, no colorblind concerns, good contrast
7886
- id: VQ-05
7987
name: Layout Balance
80-
score: 5
88+
score: 4
8189
max: 5
8290
passed: true
83-
comment: Good margins, well-proportioned plot area
91+
comment: Good canvas utilization ~60-70%; annotation slightly crowded at top-right
92+
edge
8493
- id: VQ-06
8594
name: Axis Labels
86-
score: 1
95+
score: 2
8796
max: 2
8897
passed: true
89-
comment: Y-axis has units "(daily count)" but X-axis just says "Date" without
90-
format specification
98+
comment: 'Descriptive labels with context: Date (January 2024) and Visitors
99+
(daily count)'
91100
- id: VQ-07
92101
name: Grid & Legend
93102
score: 0
94103
max: 2
95-
passed: true
96-
comment: Grid is subtle at alpha 0.1, but no legend shown (showlegend=False)
97-
- for a single series this is acceptable but loses points
104+
passed: false
105+
comment: Grid subtle at alpha 0.15, but legend disabled entirely (showlegend=False)
98106
spec_compliance:
99107
score: 25
100108
max: 25
@@ -104,62 +112,63 @@ review:
104112
score: 8
105113
max: 8
106114
passed: true
107-
comment: Correct area chart using fill="tozeroy"
115+
comment: Correct area chart using go.Scatter with fill=tozeroy
108116
- id: SC-02
109117
name: Data Mapping
110118
score: 5
111119
max: 5
112120
passed: true
113-
comment: Datetime on x-axis, numeric visitors on y-axis
121+
comment: X is datetime, Y is numeric visitors — correctly assigned
114122
- id: SC-03
115123
name: Required Features
116124
score: 5
117125
max: 5
118126
passed: true
119-
comment: Semi-transparent fill (0.4), gridlines present, clear axis labels
127+
comment: Semi-transparent fill, gridlines, clear axis labels, smooth spline
128+
line
120129
- id: SC-04
121130
name: Data Range
122131
score: 3
123132
max: 3
124133
passed: true
125-
comment: Y-axis starts at 0, all data visible
134+
comment: All data visible, y-axis starts at 0 appropriate for area charts
126135
- id: SC-05
127136
name: Legend Accuracy
128137
score: 2
129138
max: 2
130139
passed: true
131-
comment: N/A for single series, name is descriptive
140+
comment: Single series named Daily Visitors, accurate in hover
132141
- id: SC-06
133142
name: Title Format
134143
score: 2
135144
max: 2
136145
passed: true
137-
comment: Correctly formatted as "Daily Website Visitors · area-basic · plotly
138-
· pyplots.ai"
146+
comment: 'Matches required format: spec-id · library · pyplots.ai'
139147
data_quality:
140148
score: 18
141149
max: 20
142150
items:
143151
- id: DQ-01
144152
name: Feature Coverage
145-
score: 7
153+
score: 6
146154
max: 8
147155
passed: true
148-
comment: Shows trend, weekly pattern, and variance - good demonstration of
149-
area chart strengths. Could show more dramatic volume changes.
156+
comment: Shows weekly cyclical pattern, upward trend, and variability; only
157+
30 points at low end of spec range
150158
- id: DQ-02
151159
name: Realistic Context
152160
score: 7
153161
max: 7
154162
passed: true
155-
comment: Website traffic is a perfect real-world scenario for area charts
163+
comment: Daily website visitors is a realistic neutral business scenario from
164+
spec examples
156165
- id: DQ-03
157166
name: Appropriate Scale
158-
score: 4
167+
score: 5
159168
max: 5
160169
passed: true
161-
comment: Values 4000-7000 are plausible for a mid-size website, though somewhat
162-
high minimum
170+
comment: Values 2000-7135 daily visitors perfectly realistic for small-to-medium
171+
website
163172
code_quality:
164173
score: 10
165174
max: 10
@@ -169,41 +178,41 @@ review:
169178
score: 3
170179
max: 3
171180
passed: true
172-
comment: 'Simple linear flow: imports → data → plot → save'
181+
comment: Clean Imports-Data-Plot-Save structure, no functions or classes
173182
- id: CQ-02
174183
name: Reproducibility
175184
score: 3
176185
max: 3
177186
passed: true
178-
comment: np.random.seed(42) is set
187+
comment: np.random.seed(42) set at top
179188
- id: CQ-03
180189
name: Clean Imports
181190
score: 2
182191
max: 2
183192
passed: true
184-
comment: Only numpy, pandas, plotly.graph_objects used
193+
comment: 'All imports used: numpy, pandas, plotly.graph_objects'
185194
- id: CQ-04
186195
name: No Deprecated API
187196
score: 1
188197
max: 1
189198
passed: true
190-
comment: Uses current Plotly API
199+
comment: Uses current plotly API
191200
- id: CQ-05
192201
name: Output Correct
193202
score: 1
194203
max: 1
195204
passed: true
196-
comment: Saves as plot.png and plot.html
205+
comment: Saves as plot.png with 1600x900 scale=3 = 4800x2700
197206
library_features:
198207
score: 2
199208
max: 5
200209
items:
201210
- id: LF-01
202-
name: Uses distinctive library features
211+
name: Distinctive Features
203212
score: 2
204213
max: 5
205214
passed: false
206-
comment: Uses basic go.Scatter with fill, but doesn't leverage Plotly's interactive
207-
features like hover templates, range sliders, or annotations that would
208-
enhance the visualization
215+
comment: Uses hovertemplate and spline shape (Plotly-specific), but HTML export
216+
with range slider only applied after PNG save. Could better leverage Plotly
217+
features in static output.
209218
verdict: APPROVED

0 commit comments

Comments
 (0)