当前位置:   article > 正文

Python折线图_plt.text(x,y,text,ha='center',va='bottom',fontsize

plt.text(x,y,text,ha='center',va='bottom',fontsize=5)
  1. # -*-coding:gb2312-*-
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. # 中文乱码问题
  5. plt.rcParams['font.sans-serif']=['SimHei']
  6. plt.rcParams['axes.unicode_minus']=False
  7. x = np.array(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'])
  8. y1 = np.array([0,0,0,0,0,7896,5235,5235,4569,4568,4562,9564])
  9. y2 = np.array([2562,2235,2569,2895,1235,2568,2895,2145,2854,1256,2632,1458])
  10. # marker="o",设置断点为实点,markerfacecolor='none'代表线条穿过实点
  11. plt.plot(x,y1,color="red",marker="o",markerfacecolor='none')
  12. plt.plot(x,y2,color="black",marker="o",markerfacecolor='none')
  13. # 标注数值
  14. for a, b in zip(x, y1):
  15. plt.text(a, b, b, ha='center', va='bottom', fontsize=10)
  16. for a, b in zip(x, y2):
  17. plt.t
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/426556
推荐阅读
相关标签
  

闽ICP备14008679号