我试图在使用pylab的subplot()函数进行排列的一些简单线图上绘制图像。但是,当我调用imshow时,似乎会改变子图的边界,即使使用set_position函数,我也无法更改这些边界。当覆盖图像时,pylab子图边界发生了变化
基本上,我想顶部的subplot与this image的底部宽度相同。
我试过关闭自动缩放按照this post和我没有区别。
这里是我的源:
import pylab as pl
#Plotting results
F=pl.figure()
#First plot the unzoomed plot
ax1=pl.subplot(211)
ax2=pl.subplot(212)
#Not relevant to problem... ax1.plot() & ax2.plot() commands
for bl in range(len(bondLengths)):
ls=styles[bl]
lw=widths[bl]
for cf in range(len(chgcarfiles)):
c=colors[cf]
avgi=avgIBLs[cf][bl]
L=len(avgi)
ax1.plot([bondLengths[bl]*(x+0.5)/L for x in range(-1,L/2,1)],avgi[len(avgi)/2-1:],c=c,ls=ls,lw=lw)
ax2.plot([bondLengths[bl]*(x+0.5)/L for x in range(-1,L/2,1)],avgi[len(avgi)/2-1:],c=c,ls=ls,lw=lw)
ax1.set_xlim([0,2.5])
ax1.set_ylim([0.5,4.9])
ax2.set_xlim([0,1.2])
ax2.set_ylim([0.88,0.96])
#Load up & insert an image
slice=pl.loadtxt("somedata1")
ax1.autoscale(False)
ax1.imshow(slice,extent=[0.05,0.75,3.4,4.1])
pl.figtext(0.45,0.03,r"Distance ($\AA$)")
pl.figtext(0.05,0.65,r"Partial Charge Density ($\rho/rho_{avg}$)",rotation='vertical')
pl.show()
当然它的长宽比 I认为这是我没有检查的财产。它总是你想到的最后一个。谢谢您的帮助。 –
2012-04-24 02:32:22