【发布时间】:2017-03-31 18:59:00
【问题描述】:
我正在尝试创建一个类似于 this question.
为什么我只得到两个面板,即只有 gs2:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
def main():
fig = plt.figure()
gs1 = gridspec.GridSpec(1,4)
gs2 = gridspec.GridSpec(2,4)
for n in range(4):
ax00 = plt.subplot(gs1[0,n])
ax10 = plt.subplot(gs2[0,n])
ax11 = plt.subplot(gs2[1,n])
ax00.plot([0,0],[0,1*n],color='r')
ax10.plot([0,1],[0,2*n],color='b')
ax11.plot([0,1],[0,3*n],color='g')
plt.show()
main()
这给了我这个:
最后我想要一个像这样的图:
我使用问题末尾的代码获得的。但是,我想要gs2.update(hspace=0) 给出的图的可移动性(我尝试使用gridspec 的原因)。 IE。我想删除最后一行和第二行之间的空格。
def whatIwant():
f, axarr = plt.subplots(3,4)
for i in range(4):
axarr[0][i].plot([0,0],[0,1*i],color='r')
axarr[1][i].plot([0,1],[0,2*i],color='b') #remove the space between those and be able to move the plots where I want
axarr[2][i].plot([0,1],[0,3*i],color='g')
plt.show()
【问题讨论】:
-
您好 ImportanceOfBeingErnest,我更新了问题。对不起,我和往常一样有点简约。现在清楚了吗?
标签: python matplotlib