There is an example of a watermark distributed with matplotlib, which is similar. Starting with this code, we can change as follows:
Use ax.imshow to build the image first. I do this because the extent parameter affects the final degree of ax . Since we want the final degree to be determined using plt.plot(...) , we will return it last.
myaximage = ax.imshow(im, aspect='auto', extent=(1,15,0.3,0.7), alpha=0.5, origin='upper', zorder=-1)
Instead of extent=myaxe.axis() use extent to control the position and size of the image. extent=(1,15,0.3,0.7) places the image in a rectangle with (1, 0.3) as the lower left corner and (15, 0.7) in the upper right corner.
With origin='upper' index [0,0] the im array is placed in the upper left corner. Using origin='lower' it was placed in the lower left corner.
import numpy as np import matplotlib.pyplot as plt import matplotlib.cbook as cbook import matplotlib.image as image np.random.seed(1) datafile = cbook.get_sample_data('logo2.png', asfileobj=False) im = image.imread(datafile) fig, ax= plt.subplots() myaximage = ax.imshow(im, aspect='auto', extent=(1,15,0.3,0.7), alpha=0.5, zorder=-1) ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=1.0, mfc='orange') ax.grid() plt.show()

If you want to expand the image and copy it within the area, you may also need to use ax.set_xlim and ax.set_ylim :
myaximage = ax.imshow(im, aspect='auto', extent=(-1,25,0.3,0.7), alpha=0.5, zorder=-1, origin='upper') ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=1.0, mfc='orange') ax.set_xlim(0,20) ax.set_ylim(0,1)

Or, for more control, you can copy the image to an arbitrary path using myaximage.set_clip_path :
import numpy as np import matplotlib.pyplot as plt import matplotlib.cbook as cbook import matplotlib.image as image import matplotlib.patches as patches np.random.seed(1) datafile = cbook.get_sample_data('logo2.png', asfileobj=False) im = image.imread(datafile) fig, ax= plt.subplots() myaximage = ax.imshow(im, aspect='auto', extent=(-5,25,0.3,0.7), alpha=0.5, origin='upper', zorder=-2)
