目前,我制作了一个子图(使用matplotlib
)
import matplotlib.pyplot as plt
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
我想在我的图中有一个可变数量(n)的子图,名为 ax1, ax2, ... axn 所以它应该类似于
mylist = []
for num in xrange(n):
mylist.append('ax'+str(num))
fig, (mylist) = plt.subplots(n, sharex=True)
但是,这不起作用,因为它只是覆盖“mylist”而不是使用列表中的名称。
另一种解决方案是,如果我没有创建列表而只使用它为轴创建的名称,但是,我不知道如何访问这些名称。如果我尝试使用
mylist[0]
控制台说
<matplotlib.axes._subplots.AxesSubplot object at 0x09BFAEF0>
如何使用此数字绘制一条线,例如
ax1.plot(data[:,0], data[:,1]