import matplotlib.pyplot as plt
import numpy as np
# 产品销售额数据
product_a = [1000, 1200, 1500, 1800, 2000]
product_b = [800, 900, 1200, 1500, 1700]
product_c = [600, 800, 1000, 1200, 1400]
# 年份数据
years = ['2019', '2020', '2021', '2022', '2023']
# 绘制柱状图
x = np.arange(len(years))
width = 0.2
plt.bar(x - width, product_a, width, label='Product A')
plt.bar(x, product_b, width, label='Product B')
plt.bar(x + width, product_c, width, label='Product C')
plt.title('Annual Sales by Product')
plt.xlabel('Year')
plt.ylabel('Sales ($)')
plt.xticks(x, years)
plt.legend()
plt.show()