import matplotlib.pyplot as plt
plt.plot([3,1,4,5,2])
plt.ylabel("grade")
plt.savefig('test',dpi=600)
plt.show
import matplotlib.pyplot as plt
plt.plot([0,2,4,6,8],[3,1,4,5,2])
plt.ylabel("grade")
plt.axis([-1,10,0,6])
plt.show
import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.exp(-t)*np.cos(2*np.pi*t)
a=np.arange(0.0,5.0,0.02)
plt.subplot(211)
plt.plot(a,f(a))
plt.subplot(2,1,2)
plt.plot(a,np.cos(2*np.pi*a),'r--')
plt.show
pyplot的plot()函数
plt.plot(x,y,format_string,**kwargs)
import numpy as np
import matplotlib.pyplot as plt
a=np.arange(10)
plt.plot(a,a*1.5,a,a*2.5,a,a*3.5,a,a*4,5)
plt.show
import numpy as np
import matplotlib.pyplot as plt
a=np.arange(10)
plt.plot(a,a*1.5,'go-',a,a*2.5,'rx',a,a*3.5,'*',a,a*4,5,'b-.')
plt.show
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family']='STSong'
a=np.arange(0.0,5.0,0.02)
plt.xlabel('横轴:时间')
plt.ylabel('纵轴:振幅')
plt.plot(a,np.cos(2*np.pi*a),'r--')
plt.show
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family']='STSong'
a=np.arange(0.0,5.0,0.02)
plt.xlabel('横轴:时间',fontproperties='simHei',fontsize=20)
plt.ylabel('纵轴:振幅',fontproperties='simHei',fontsize=20)
plt.plot(a,np.cos(2*np.pi*a),'r--')
plt.show