I'm trying to stick an image on top of some simple line plots which are arranged using the subplot() function of pylab. However when I call imshow it appears that the bounds of the subplot are altered and I am unable to change these bounds even using the set_position function.
Basically, I would like the top subplot to be the same width as the bottom in this image.
I have tried turning off autoscale as per this post and I get no difference.
Here's my source:
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()