-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.py
More file actions
41 lines (32 loc) · 1.06 KB
/
default.py
File metadata and controls
41 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
area-basic: Basic Area Chart
Library: matplotlib
"""
import matplotlib.pyplot as plt
import pandas as pd
# Data - Monthly sales from spec
data = pd.DataFrame(
{
"month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"sales": [120, 135, 148, 162, 175, 195, 210, 198, 185, 170, 158, 190],
}
)
# Create plot
fig, ax = plt.subplots(figsize=(16, 9))
# Plot area chart - use numeric x-axis for proper fill_between
x = range(len(data))
ax.fill_between(x, data["sales"], alpha=0.5, color="#306998")
ax.plot(x, data["sales"], color="#306998", linewidth=2)
# Set x-tick labels to month names
ax.set_xticks(x)
ax.set_xticklabels(data["month"])
# Labels and styling
ax.set_xlabel("Month", fontsize=20)
ax.set_ylabel("Sales", fontsize=20)
ax.set_title("Basic Area Chart", fontsize=20)
ax.tick_params(axis="both", labelsize=16)
ax.grid(True, alpha=0.3, linestyle="--")
# Set y-axis to start from 0 for proper area representation
ax.set_ylim(bottom=0)
plt.tight_layout()
plt.savefig("plot.png", dpi=300, bbox_inches="tight")