''''''
'''
mpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = False用来解决不能使用汉字问题,需要导入matplotlib
'''
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = False
import math
x=np.arange(0.05,3,0.05)
y1=[5 for i in x]
plt.plot(x,y1,linewidth=2,label=u'常函数:y=5')
y2=[2*i+1 for i in x]
plt.plot(x,y2,linewidth=2,label=u'一次函数:y=2x+1')
y3=[1.5*i*i-3*i+1 for i in x]
plt.plot(x,y3,linewidth=2,label=u'二次函数:y=1.5$x^2$-3x+1')
y4=[math.pow(i,2) for i in x]
plt.plot(x,y4,linewidth=2,label=u'幂函数:y=$x^2$')
y5=[math.pow(2,i) for i in x]
plt.plot(x,y5,linewidth=2,label=u'指数函数:y=$2^x$')
y6=[math.log(i,2) for i in x]
plt.plot(x,y6,linewidth=2,label=u'对数函数:y=logx2(x)')
x1=np.linspace(-4*np.pi,4*np.pi,100)
y7=[np.sin(i) for i in x1]
y8=[np.cos(i) for i in x1]
plt.plot(x1,y7,label='y=sin(x)',c='g',linewidth=2)
plt.plot(x1,y8,label='y=cos(x)',c='r',linewidth=2)
plt.legend(loc='lower right')
plt.grid(True)
plt.show()