的相对大小,我有两个地块的Python/Matplotlib - 更改插曲
import matplotlib.pyplot as plt
plt.subplot(121)
plt.subplot(122)
我想plt.subplot(122)
是一半宽plt.subplot(121)
。是否有直接的方法来设置子图的高度和宽度参数?
的相对大小,我有两个地块的Python/Matplotlib - 更改插曲
import matplotlib.pyplot as plt
plt.subplot(121)
plt.subplot(122)
我想plt.subplot(122)
是一半宽plt.subplot(121)
。是否有直接的方法来设置子图的高度和宽度参数?
调整高度比通过简单地指定几何“122
”,你隐式地获得自动的,相等大小的行和列吨。
要自定义布局网格,您需要更具体一些。请参阅Matplotlib文档中的“Customizing Location of Subplot Using GridSpec”。
参见电网规格教程:
http://matplotlib.sourceforge.net/users/gridspec.html
示例代码:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
f = plt.figure()
gs = gridspec.GridSpec(1, 2,width_ratios=[2,1])
ax1 = plt.subplot(gs[0])
ax2 = plt.subplot(gs[1])
plt.show()
也可以使用在GridSpec
的类似选项感谢您的提示。我没有权限将matplotlib.gridspec导入为gridspec。有另一种方法吗? – thenickname 2011-02-22 21:24:49
是否使用了不支持GridSpec的旧版matplotlib?你的问题还不清楚。 – JoshAdel 2011-02-22 22:45:43
@thenickname:你可以做'输入matplotlib'并调用'matplotlib.gridspac.GridSpec(1,2,等)' – heltonbiker 2011-12-07 12:25:13
可能重复[Matplotlib不同大小的子图](http://stackoverflow.com/questions/10388462/matplotlib-different-size-subplots) – Vincenzooo 2017-02-16 22:12:54