每一个 pyplot 函数都会改变 figure,比如创建figure,在figure中创建绘图区域,在绘图区域绘制线条,添加 labels 等。...你可以传递任何随机数据给 plot 命令,比如同时传入 x, y
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
对于每一个x,y 参数对都有一些可选参数用来设置 线形 和...下面创建两个子图:
import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.exp(-t) * np.cos...1个子图
plt.plot([1, 2, 3])
plt.subplot(212) # 图1中第2个子图
plt.plot([4, 5, 6])
plt.figure(2)...# 图2
plt.plot([4, 5, 6]) # 默认创建一个子图
plt.figure(1)
plt.subplot(211)