我试着画出两个不同的函数集,一次通过一个双循环。我不知道如何才能让sublot2grid对第二个数字执行操作。在
import numpy as np
from matplotlib import pyplot as plt
t=np.linspace(0,1,100)
fig1=plt.figure()
for i in range(3):
for j in range(3):
plt.subplot2grid((3,3),(i,j))
plt.plot(t,np.sin((t*np.random.random()*10)))
fig2=plt.figure()
for i in range(3):
for j in range(3):
plt.subplot2grid((3,3),(i,j))
plt.plot(t,np.cos((t*np.random.random()*10)))
plt.show()
有没有办法只用一个循环就可以做到这一点?在
你应该使用面向对象的接口。下面是一个例子:
相关问题 更多 >
编程相关推荐