import matplotlib.pyplot as plt
import numpy as np
# 模拟用户行为数据
data = {
'Weekdays': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
'Active Users': [1200, 1500, 1700, 1600, 1800]
}
x = data['Weekdays']
y = data['Active Users']
# 创建折线图
plt.figure(figsize=(8, 6))
plt.plot(x, y, marker='o')
plt.title('User Activity Over the Week')
plt.xlabel('Day of the Week')
plt.ylabel('Number of Active Users')
plt.grid(True)
plt.show()
]]>
# 创建柱状图
plt.bar(x, y, color='skyblue')
plt.title('Weekly User Activity Comparison')
plt.xlabel('Day of the Week')
plt.ylabel('Number of Active Users')
plt.show()
]]>