|
1 | | -""" pyplots.ai |
| 1 | +"""pyplots.ai |
2 | 2 | area-basic: Basic Area Chart |
3 | | -Library: letsplot 4.8.1 | Python 3.13.11 |
4 | | -Quality: 91/100 | Created: 2025-12-23 |
| 3 | +Library: letsplot 4.8.2 | Python 3.14.2 |
| 4 | +Quality: /100 | Updated: 2026-02-11 |
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import numpy as np |
|
23 | 23 | visitors = np.clip(visitors, 2000, None).astype(int) |
24 | 24 |
|
25 | 25 | df = pd.DataFrame({"date": days, "visitors": visitors}) |
26 | | -df["day_num"] = np.arange(1, len(df) + 1) |
27 | 26 |
|
28 | 27 | # Plot |
29 | 28 | plot = ( |
30 | | - ggplot(df, aes(x="day_num", y="visitors")) # noqa: F405 |
31 | | - + geom_area(fill="#306998", alpha=0.4) # noqa: F405 |
| 29 | + ggplot(df, aes(x="date", y="visitors")) # noqa: F405 |
| 30 | + + geom_area( # noqa: F405 |
| 31 | + fill="#306998", |
| 32 | + alpha=0.4, |
| 33 | + tooltips=layer_tooltips() # noqa: F405 |
| 34 | + .line("@visitors visitors") |
| 35 | + .format("date", "%b %d, %Y") |
| 36 | + .line("@date"), |
| 37 | + ) |
32 | 38 | + geom_line(color="#306998", size=2) # noqa: F405 |
| 39 | + + scale_x_datetime(format="%b %d") # noqa: F405 |
| 40 | + + scale_y_continuous(limits=[0, None]) # noqa: F405 |
33 | 41 | + labs( # noqa: F405 |
34 | | - x="Day of Month", y="Daily Visitors", title="area-basic · letsplot · pyplots.ai" |
| 42 | + x="Date", y="Daily Visitors", title="area-basic · letsplot · pyplots.ai" |
35 | 43 | ) |
36 | 44 | + ggsize(1600, 900) # noqa: F405 |
37 | 45 | + theme_minimal() # noqa: F405 |
38 | 46 | + theme( # noqa: F405 |
39 | 47 | axis_text=element_text(size=16), # noqa: F405 |
40 | 48 | axis_title=element_text(size=20), # noqa: F405 |
41 | 49 | plot_title=element_text(size=24), # noqa: F405 |
42 | | - panel_grid=element_line(color="#CCCCCC", size=0.5, linetype="dashed"), # noqa: F405 |
| 50 | + panel_grid=element_line(color="#CCCCCC", size=0.3, linetype="dashed"), # noqa: F405 |
43 | 51 | ) |
44 | 52 | ) |
45 | 53 |
|
|
0 commit comments