Skip to content

Commit 6554ebe

Browse files
MarkusNeusingerclaude[bot]github-actions[bot]
authored
feat: add area-basic implementation (9 libraries) (#527)
## Summary Adds `area-basic` plot implementation. ### Libraries - **Merged:** 9 (all libraries) - **Not Feasible:** 0 ### Links - **Spec:** `specs/area-basic.md` - **Parent Issue:** #514 Closes #514 --- :robot: *Auto-generated by pyplots CI* --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent bd7dca8 commit 6554ebe

File tree

3 files changed

+24
-36
lines changed

3 files changed

+24
-36
lines changed

plots/altair/area/area-basic/default.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
# Data
1111
data = pd.DataFrame(
1212
{
13-
"month": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
14-
"sales": [100, 150, 130, 180, 200, 220, 195, 240, 260, 230, 280, 310],
13+
"month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
14+
"sales": [120, 135, 148, 162, 175, 195, 210, 198, 185, 170, 158, 190],
1515
}
1616
)
1717

1818
# Create chart with area and line
1919
chart = (
2020
alt.Chart(data)
21-
.mark_area(opacity=0.5, color="#306998", line={"color": "#306998", "strokeWidth": 2})
21+
.mark_area(opacity=0.7, color="#306998", line={"color": "#306998", "strokeWidth": 2})
2222
.encode(
23-
x=alt.X("month:Q", title="Month", axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
23+
x=alt.X("month:O", title="Month", sort=None, axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
2424
y=alt.Y("sales:Q", title="Sales", axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
2525
)
26-
.properties(width=1600, height=900, title=alt.TitleParams(text="Basic Area Chart", fontSize=20))
26+
.properties(width=1600, height=900, title=alt.TitleParams(text="Monthly Sales", fontSize=20))
2727
.configure_view(strokeWidth=0)
2828
.configure_axis(grid=True, gridOpacity=0.3)
2929
)

plots/highcharts/area/area-basic/default.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,32 @@
1515
from selenium.webdriver.chrome.options import Options
1616

1717

18-
# Data - Monthly sales example
19-
sales = [100, 150, 130, 180, 200, 220, 195, 240, 280, 310, 290, 350]
18+
# Data
19+
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20+
sales = [120, 135, 148, 162, 175, 195, 210, 198, 185, 170, 158, 190]
2021

21-
# Create chart
22+
# Create chart with container (required for headless export)
2223
chart = Chart(container="container")
2324
chart.options = HighchartsOptions()
2425

2526
# Chart configuration
26-
chart.options.chart = {
27-
"type": "area",
28-
"width": 4800,
29-
"height": 2700,
30-
"backgroundColor": "#ffffff",
31-
"style": {"fontFamily": "Arial, sans-serif"},
32-
}
27+
chart.options.chart = {"type": "area", "width": 4800, "height": 2700, "backgroundColor": "#ffffff"}
3328

3429
# Title
35-
chart.options.title = {"text": "Monthly Sales Trend", "style": {"fontSize": "48px"}}
30+
chart.options.title = {"text": "Monthly Sales", "style": {"fontSize": "48px"}}
3631

37-
# Axes
32+
# X-axis with categories
3833
chart.options.x_axis = {
34+
"categories": months,
3935
"title": {"text": "Month", "style": {"fontSize": "40px"}},
40-
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
41-
"labels": {"style": {"fontSize": "32px"}, "enabled": True},
42-
"gridLineWidth": 1,
43-
"gridLineColor": "rgba(0, 0, 0, 0.1)",
44-
"tickmarkPlacement": "on",
36+
"labels": {"style": {"fontSize": "32px"}},
4537
}
4638

39+
# Y-axis
4740
chart.options.y_axis = {
48-
"title": {"text": "Sales ($)", "style": {"fontSize": "40px"}},
41+
"title": {"text": "Sales", "style": {"fontSize": "40px"}},
4942
"labels": {"style": {"fontSize": "32px"}},
50-
"gridLineWidth": 1,
51-
"gridLineColor": "rgba(0, 0, 0, 0.1)",
43+
"gridLineColor": "#e0e0e0",
5244
}
5345

5446
# Legend
@@ -59,13 +51,13 @@
5951
series.data = sales
6052
series.name = "Sales"
6153
series.color = "#306998"
62-
series.fill_opacity = 0.5
63-
series.line_width = 4
64-
series.marker = {"enabled": True, "radius": 6, "fillColor": "#306998", "lineWidth": 2, "lineColor": "#ffffff"}
54+
series.fill_opacity = 0.6
55+
series.line_width = 3
56+
series.marker = {"enabled": True, "radius": 6, "fillColor": "#306998"}
6557

6658
chart.add_series(series)
6759

68-
# Download Highcharts JS
60+
# Download Highcharts JS for inline embedding
6961
highcharts_url = "https://code.highcharts.com/highcharts.js"
7062
with urllib.request.urlopen(highcharts_url, timeout=30) as response:
7163
highcharts_js = response.read().decode("utf-8")
@@ -94,16 +86,12 @@
9486
chrome_options.add_argument("--no-sandbox")
9587
chrome_options.add_argument("--disable-dev-shm-usage")
9688
chrome_options.add_argument("--disable-gpu")
97-
chrome_options.add_argument("--window-size=4800,2800")
89+
chrome_options.add_argument("--window-size=4800,2700")
9890

9991
driver = webdriver.Chrome(options=chrome_options)
100-
driver.set_window_size(4800, 2800)
10192
driver.get(f"file://{temp_path}")
10293
time.sleep(5)
103-
104-
# Get the container element and screenshot it directly
105-
container = driver.find_element("id", "container")
106-
container.screenshot("plot.png")
94+
driver.save_screenshot("plot.png")
10795
driver.quit()
10896

10997
Path(temp_path).unlink()

plots/matplotlib/fill_between/area-basic/default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# Labels and styling
3131
ax.set_xlabel("Month", fontsize=20)
3232
ax.set_ylabel("Sales", fontsize=20)
33-
ax.set_title("Monthly Sales Volume", fontsize=20)
33+
ax.set_title("Basic Area Chart", fontsize=20)
3434
ax.tick_params(axis="both", labelsize=16)
3535
ax.grid(True, alpha=0.3, linestyle="--")
3636

0 commit comments

Comments
 (0)