pyplot的文本显示

 1 import numpy as np
 2 import matplotlib.pyplot as plt
 3 
 4 a = np.arange(0.0,5,0.02)
 5 plt.plot(a,np.cos(2*np.pi*a),'r--')
 6 plt.xlabel('横轴:时间',fontproperties='SimHei',fontsize=15,color='green')
 7 plt.ylabel('纵轴:振幅',fontproperties='SimHei',fontsize=15)
 8 plt.title('正弦波实例$y=cos(2\pi x)$',fontproperties='SimHei',fontsize=25)
 9 plt.text(2,1,'$\mu=100$',fontsize=15)
10 
11 plt.axis([-1,6,-2,2])
12 plt.grid(True)
13 plt.show()

 plt.annotate(s,xy=arrow_crd,xytext=text_crd,arrowprops=dict)

 1 import numpy as np
 2 import matplotlib.pyplot as plt
 3 
 4 a = np.arange(0.0,5,0.02)
 5 plt.plot(a,np.cos(2*np.pi*a),'r--')
 6 
 7 plt.xlabel('横轴:时间',fontproperties='SimHei',fontsize=15,color='green')
 8 plt.ylabel('纵轴:振幅',fontproperties='SimHei',fontsize=15)
 9 plt.title('正弦波实例$y=cos(2\pi x)$',fontproperties='SimHei',fontsize=25)
10 plt.annotate('$\mu=100$',xy=(2,1),xytext=(3,1.5),arrowprops=dict(facecolor='black',shrink=0.1,width=2))
11 
12 plt.axis([-1,6,-2,2])
13 plt.grid(True)
14 plt.show()

 

posted @ 2017-08-08 16:32  心有琳系  Views(552)  Comments(0Edit  收藏  举报