如何在`subplots()`中使用`GridSpec()`

8 浏览
0 Comments

如何在`subplots()`中使用`GridSpec()`

有一些(例子)Stack Overflow的帖子介绍了如何在subplotting中使用GridSpec。我想要实现但一直无法成功的是,允许使用GridSpec与subplots一起使用,像这样,我可以用循环控制的索引替换实际的数组和列表索引:

gs = gridspec.GridSpec(4, 1, height_ratios=[2, 2, 1, 1])

tPlot, axes = plt.subplots(4, sharex=True, sharey=False)

tPlot.suptitle(node, fontsize=20)

axes[0].plot(targetDay[0], gs[0])

axes[1].plot(targetDay[1], gs[1])

axes[2].scatter(targetDay[2], gs[2])

axes[3].plot(targetDay[3], gs[3])

毋庸置疑,这段代码不起作用,它只是一个例子。

0