编辑代码

# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
import matplotlib.pyplot as plt

# 年份
years = ['2020年', '2021年', '2022年', '2023年', '2024年']

# 各公司的市场份额
konghui = [0, 2, 10, 44.5, 41.3]
tuopu = [0, 1, 5, 15, 25.8]
baolong = [0, 1, 8, 20.7, 19.6]
webco = [40, 30, 35.8, 18, 7.8]
dalu = [30, 25, 19.2, 7.8, 5]
other = [30, 41, 21.2, 4, 10.5]

# 创建图形和轴
fig, ax = plt.subplots()

# 绘制折线图
ax.plot(years, konghui, label='孔辉科技', marker='o')
ax.plot(years, tuopu, label='拓普集团', marker='o')
ax.plot(years, baolong, label='保隆科技', marker='o')
ax.plot(years, webco, label='威巴克', marker='o')
ax.plot(years, dalu, label='大陆集团', marker='o')
ax.plot(years, other, label='其他', marker='o')

# 添加标题和标签
ax.set_title('汽车空气悬架市场变化统计')
ax.set_xlabel('年份')
ax.set_ylabel('市场份额 (%)')

# 显示图例
ax.legend()

# 显示网格
ax.grid(True)

# 显示图形
plt.show()