Py学习  »  Python

Python子块3以2x2矩阵(金字塔)绘制

searchingforanswers • 4 年前 • 912 次点击  

如果我使用 plt.subplot2grid colspan=2 这里是我当前的代码:

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)

enter image description here

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56032
 
912 次点击  
文章 [ 2 ]  |  最新文章 4 年前
Josh
Reply   •   1 楼
Josh    4 年前

使用轴 set_aspect 控制轴形状的函数。具体来说,在您给出的示例中,添加以下行:

ax3.set_aspect('equal')

得到你在(a)中所画的东西。

Quang Hoang
Reply   •   2 楼
Quang Hoang    4 年前

您可以将网格更改为 (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)

输出:

enter image description here