-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvisual.py
More file actions
34 lines (29 loc) · 1002 Bytes
/
visual.py
File metadata and controls
34 lines (29 loc) · 1002 Bytes
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
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
data = {
"Month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"Sales": [1200, 1500, 1700, 1600, 1800, 2100]
}
df = pd.DataFrame(data)
sns.set_theme(style="whitegrid")
plt.figure(figsize=(10, 5))
sns.lineplot(data=df, x="Month", y="Sales", marker="o", linewidth=2.5, color="mediumblue")
plt.title("Monthly Sales Trend", fontsize=14, weight="bold")
plt.xlabel("Month", fontsize=12)
plt.ylabel("Sales (USD)", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.tight_layout()
plt.show()
plt.figure(figsize=(10, 5))
sns.barplot(data=df, x="Month", y="Sales", palette="coolwarm")
plt.title("Monthly Sales Report", fontsize=14, weight="bold")
plt.xlabel("Month", fontsize=12)
plt.ylabel("Sales (USD)", fontsize=12)
for index, value in enumerate(df["Sales"]):
plt.text(index, value + 50, f"${value}", ha='center', fontsize=10)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.tight_layout()
plt.show()