fork download
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. # 示例数据:每分钟的收益(假设 15 分钟内有 15 个数据点)
  5. minutes = np.arange(1, 16) # 1 到 15 分钟
  6. earnings = np.random.uniform(-2, 3, 15) # 随机生成的收益数据
  7.  
  8. # 创建柱状图
  9. plt.figure(figsize=(10, 6))
  10. plt.bar(minutes, earnings, color=np.where(earnings >= 0, 'green', 'red'), alpha=0.7)
  11.  
  12. # 添加标题和标签
  13. plt.title('15 分钟内的收益柱状图', fontsize=16)
  14. plt.xlabel('分钟', fontsize=12)
  15. plt.ylabel('收益', fontsize=12)
  16.  
  17. # 添加网格线(可选)
  18. plt.grid(axis='y', linestyle='--', alpha=0.7)
  19.  
  20. # 显示图形
  21. plt.show()
Success #stdin #stdout 0.73s 53984KB
stdin
Standard input is empty
stdout
Standard output is empty