import matplotlib.pyplot as plt import numpy as np from matplotlib import font_manager
my_font = font_manager.FontProperties(fname= "C:/Windows/Fonts/msyh.ttc") k=10 x=np.arange(k) y=np.random.rand(k) plt.bar(x,y) #画出x和y的柱状图 # plt.barh(x,y) #画出x和y的横向柱状图 for i in x: #给柱状图标出数值 plt.text(i,y[i],"%.2f"% y[i],ha='center',va='bottom') #2是浮点数的位数 # plt.text(0.0,0.5,"don`s move",fontdict={'size':'16','color':'b'}) plt.annotate('note!!',xy=(2,0.21),xytext=(2,0.4),fontsize=16, arrowprops=dict(facecolor='red',shrink=0.01)) plt.show()