在python matplotlib中,我想将轴与x,y轴对齐

时间:2019-04-16 00:41:18

标签: python python-3.x matplotlib

调整轴尺寸和子图中的轴移动。

但是图像比例必须恒定(See figure

我在set_position中使用了set_anchorplt,轴,但找不到答案。

总而言之,我需要知道如何移动img并调整2x2子图中的ax1大小。

figg, axes = plt.subplots(2,2, figsize=(22,15))

ax1 = axes[0,0]
ax2 = axes[0,1]
ax3 = axes[1,0]
ax4 = axes[1,1]

fts=15

im1 = ax1.imshow(d[1], extent=L2_extent, cmap="hsv")
ax1.axis('scaled')
ax1.grid(color='b', linestyle=':', linewidth=0.2)

divider = make_axes_locatable(ax1)

cax = divider.append_axes('right', size ='5%', pad=0.05)
bar = figg.colorbar(im1, cax=cax, orientation='vertical')

caxb = divider.append_axes('bottom', size ='15%', pad=0.7)
projb = caxb.plot(d[2][4], d[2][5])
caxb.set_xlim(2, 56)
caxb.grid(True)
caxb.yaxis.set_label_position('right')

caxl = divider.append_axes("left", size = "12%", pad = 0.7)
projl = caxl.plot(d[2][7], d[2][6])
caxl.invert_xaxis()
caxl.set_ylim(1, 55)
caxl.grid(True) 

im2=ax2.imshow(d[0], extent=L1_extent, cmap="hsv")
ax2.axis('scaled')
ax2.grid(color='b', linestyle=':', linewidth=0.2)

divider = make_axes_locatable(ax2)

cax = divider.append_axes("right", size= "5%", pad = 0.05)
bar = figg.colorbar(im2, cax = cax, orientation = 'vertical')

caxb = divider.append_axes("bottom", size = "15%", pad = 0.10)
projb = caxb.plot(d[2][0], d[2][1])
caxb.set_xlim(56, 139)


im3=ax3.imshow(d[0], extent=L1_extent, cmap="hsv")
ax3.axis('scaled')      
ax3.grid(color='b', linestyle=':', linewidth=0.2)

divider = make_axes_locatable(ax3)

cax = divider.append_axes("right", size= "5%", pad = 0.05)
bar = figg.colorbar(im3, cax = cax, orientation = 'vertical')

caxb = divider.append_axes("bottom", size = "15%", pad = 0.1)
projb = caxb.plot(d[2][0], d[2][1])

caxb.grid()
caxb.set_xlim(56,139)


plt.tight_layout()

0 个答案:

没有答案