python---绘图模块matplotlib.pyplot

plot()中的两个参数对应着X,Y坐标。

代码如下:

import matplotlib.pyplot as plt;
import numpy as np;
plt.plot([1,6,3],[4,5,6])
plt.plot([1,6,3],[4,5,6])

plt.show()#show()方法,把绘制好的图放在输出。
python---绘图模块matplotlib.pyplot

设置在jupyter中matplotlib的显示情况

1.%matplotlib tk 在GUI中显示
2.%matplotlib inline 在行内显示

import matplotlib.pyplot as plt;
import numpy as np;
%matplotlib inline
plt.plot([1,2,3],[2,3,4])
plt.show()

python---绘图模块matplotlib.pyplot

matplotlib:图形 figure

figure:图形,matplotlib中的所有图像都是位于figure对象中,一个图像只能有一个figure对象。matplotlib 的 figure 就是一个 单独的 figure 小窗口, 小窗口里面还可以有更多的小图片.

x=np.arange(-3,3,0.1)
y1=np.sin(x)
y2=np.cos(x)

plt.figure#创建第一个图形。
plt.plot(x,y1)
#plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.show()

python---绘图模块matplotlib.pyplot
plt.plot([1,2,3],[5,7,4],‘bo–’)
plt.show()
python---绘图模块matplotlib.pyplot