Python子地块3在2x2矩阵(金字塔)中绘制
我想绘制一个子图,如版本“a”所示。 如果我使用Python子地块3在2x2矩阵(金字塔)中绘制,python,matplotlib,subplot,Python,Matplotlib,Subplot,我想绘制一个子图,如版本“a”所示。 如果我使用plt.subplot2grid和colspan=2我得到了版本“b)”我不想要的东西。 以下是我当前的代码: ax1.subplot2grid((2,2), (0,0)) ax1.plot(m[:,0], m[:,8], color = "0") ax2.subplot2grid((2,2), (0,1)) ax2.plot(m[:,0], m[:,9], color = "0") ax3.subplot2grid((2,2), (1,0)) a
plt.subplot2grid
和colspan=2
我得到了版本“b)”我不想要的东西。
以下是我当前的代码:
ax1.subplot2grid((2,2), (0,0))
ax1.plot(m[:,0], m[:,8], color = "0")
ax2.subplot2grid((2,2), (0,1))
ax2.plot(m[:,0], m[:,9], color = "0")
ax3.subplot2grid((2,2), (1,0))
ax3.plot(m[:,0], m[:,10], color = "0", colespan=2)
提前谢谢!
使用轴的功能控制轴的形状。具体来说,在您给出的示例中,添加以下行:
ax3.set_aspect('equal')
要获得(a)中的图片,请使用轴的功能控制轴的形状。具体来说,在您给出的示例中,添加以下行:
ax3.set_aspect('equal')
要获得(a)中的图片,您可以将网格更改为
(2,4)
,并在每个轴上放置colspan=2
:
m = np.array([[0,1],[1,0]])
fig = plt.figure()
ax = plt.subplot2grid((2,4),(0,0), colspan=2)
ax.imshow(m)
ax1 = plt.subplot2grid((2,4),(0,2), colspan=2)
ax1.imshow(m)
ax2 = plt.subplot2grid((2,4),(1,1), colspan=2)
ax2.imshow(m)
输出:
您可以将网格更改为
(2,4)
,并在每个轴上放置colspan=2
:
m = np.array([[0,1],[1,0]])
fig = plt.figure()
ax = plt.subplot2grid((2,4),(0,0), colspan=2)
ax.imshow(m)
ax1 = plt.subplot2grid((2,4),(0,2), colspan=2)
ax1.imshow(m)
ax2 = plt.subplot2grid((2,4),(1,1), colspan=2)
ax2.imshow(m)
输出: