前言:
matplotlib是python最常用的绘图库,能帮你画出美丽的各种图
导入
包含了中文显示,屏外显示
import matplotlib.pyplot as plt
import matplotlib...image.png
创建子图
在一个figure中显示多个图片
面向过程的方法,一步一步创建
x1=[1,2,3]
y1=[5,7,4]
x2=[1,2,3]
y2=[10,14,12]
plt.figure...()
plt.subplot(221)#第一个子图
plt.plot(x1,y1,'ro--')
plt.subplot(223)
plt.plot(x2,y2,'bo-')#第二个子图
plt.show...面向对象创建子图
#创建图形
fig=plt.figure()
#创建子图
ax1=fig.add_subplot(221)
ax2=fig.add_subplot(222)
ax3=fig.add_subplot...(212)
#在子图上画图
ax1.plot(np.random.randn(50).cumsum(),'r-')
ax2.plot(np.random.randn(50).cumsum(),'b-'