我想在Matplotlib中嵌入两个子图(嵌入在GUI中):
在这两种情况下,这些都是相同的宽度。
GridSpec似乎不允许绝对尺寸,只允许相对尺寸。我不希望Subplot 1在调整窗口大小的情况下拉伸它的高度。
我该怎么做?
答案 0 :(得分:1)
如果我理解了您的问题,那么此代码可能有所帮助。它使用轴而不是子图,这样可以更好地控制图中图形的位置。
import pylab as pl
# use pylab.Axes(figure, [left, bottom, width, height])
# where each value in the frame is between 0 and 1
#top
figure = pl.figure()
axes = pl.Axes(figure, [.4,.4,.25,.25])
figure.add_axes(axes)
pl.plot([1, 2, 3], [1, 2, 3])
#bottom
axes = pl.Axes(figure, [.4,.1,.25,.25])
figure.add_axes(axes)
pl.plot([1, 2, 3], [1, 2, 3])
pl.show()
如果这不是您的意思,请发布一段代码或示例以澄清。