前言:
matplotlib是python最常用的绘图库,能帮你画出美丽的各种图
导入
包含了中文显示,屏外显示
import matplotlib.pyplot as plt
import matplotlib...['axes.unicode_minus'] = False
画出第一个图形
figure图形,画的每个图只有一个figure对象
x= np.arange(-3,3,0.1)
y1=np.sin...(x)
#创建第一个figure
plt.figure()
#绘图
plt.plot(x,y1)
#表现出来
plt.show()
?...image.png
创建子图
在一个figure中显示多个图片
面向过程的方法,一步一步创建
x1=[1,2,3]
y1=[5,7,4]
x2=[1,2,3]
y2=[10,14,12]
plt.figure...面向对象创建子图
#创建图形
fig=plt.figure()
#创建子图
ax1=fig.add_subplot(221)
ax2=fig.add_subplot(222)
ax3=fig.add_subplot