fork download
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. # 设置中文显示,确保系统中安装了支持中文的字体,例如SimHei。
  5. plt.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
  6. plt.rcParams['axes.unicode_minus'] = False # 正确显示负号
  7.  
  8. # 创建数据
  9. years = np.array([2018, 2019, 2020, 2021, 2022])
  10. market_growth = np.array([3.2, 4.0, 4.8, 5.4, 5.8]) # 假设的市场增长率数据
  11.  
  12. # 绘图
  13. plt.figure(figsize=(10, 6))
  14. plt.plot(years, market_growth, marker='o', linestyle='-', color='b')
  15. plt.title('数字艺术市场过去五年的增长率') # 图表标题
  16. plt.xlabel('年份') # x轴标签
  17. plt.ylabel('市场增长率(%)') # y轴标签
  18. plt.grid(True) # 显示网格
  19. plt.xticks(years) # 设置x轴刻度
  20. plt.ylim(3, 6) # 设置y轴的范围
  21.  
  22. # 显示图表
  23. plt.show()
  24.  
Success #stdin #stdout 0.79s 55568KB
stdin
Standard input is empty
stdout
Standard output is empty