Skip to content

Commit e9e0971

Browse files
update(area-basic): plotly — comprehensive quality review
Added hover templates, peak annotation, spline lines, range slider, weekly tick marks
1 parent ed0fb1b commit e9e0971

2 files changed

Lines changed: 40 additions & 16 deletions

File tree

plots/area-basic/implementations/plotly.py

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

77
import numpy as np
@@ -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")

plots/area-basic/metadata/plotly.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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:20:05+00:00'
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
13-
quality_score: 92
13+
quality_score: null
1414
impl_tags:
1515
dependencies: []
1616
techniques: []

0 commit comments

Comments
 (0)