I have attempted to overlay a grid that is on a separate axes over an image that is loaded into matplotlib using imread. The reason for the use of a separate axis is to display grid lines and detect mouse clicks using a different coordinate system rather than the default one created by matplotlib when the image is loaded. Changing the zorder of the grid axis to a higher value than the image axis works, but then the image can't be seen. Is there any other method?
ax1 = fig.add_subplot(111)
ax1.grid()
ax2 = ax1.twinx()
im = matplotlib.image.imread('pic.png')
ax2.imshow(im)
ax1.set_zorder(1) #grid is shown but image disappears
draw()