python之matplotlib系统列1-基本使用

使用import导入模块matplotlib.pyplot,并简写成plt 使用import导入模块numpy,并简写成np 

import matplotlib.pyplot as plt #imort pyplot
import numpy as np      #import numpy

x=np.linspace(-1,1,50)
y=2*x+1
plt.figure()  #difine a figure window
plt.plot(x,y) #plot the figure
plt.show()    #show the figure

 使用np.linspace定义x:范围是(-1,1);个数是50. 仿真一维数据组(x ,y)表示曲线1.

使用plt.figure定义一个图像窗口. 使用plt.plot画(x ,y)曲线. 使用plt.show显示图像.

猜你喜欢

转载自blog.csdn.net/huang_shao1/article/details/82978450