The result is:
plt.plot and plt.scatter is used in this page as an example.
You can plot by mapping function that convert the point of the plotting data to that of the image.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
img = Image.open("./lena_color.gif")
img
type(img)
img.size # returns (x, y) of the image
plt.imshow(img)
fig, ax = plt.subplots()
ax.imshow(img)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])
plt.show()
xy2imgxy = lambda x,y: (img.size[0] * x / np.max(ticklx),\
img.size[1] * (np.max(tickly) - y) / np.max(tickly))
ticklx = np.linspace(0,100,6)
tickly = np.linspace(0,100,6)
tickpx,tickpy = xy2imgxy(ticklx,tickly)
fig,ax = plt.subplots()
ax.imshow(img)
# Rewrite x,y ticks
ax.set_xticks(tickpx)
ax.set_yticks(tickpy)
ax.set_xticklabels(ticklx.astype('int'))
ax.set_yticklabels(tickly.astype('int'))
plt.show()
fig,ax = plt.subplots()
ax.imshow(img)
# Rewrite x,y ticks
ax.set_xticks(tickpx)
ax.set_yticks(tickpy)
ax.set_xticklabels(ticklx.astype('int'))
ax.set_yticklabels(tickly.astype('int'))
# Add scatter point on the image.
px,py = 20,20
imgx,imgy = xy2imgxy(px,py)
ax.scatter(imgx,imgy,s=100,lw=5,facecolor="none",edgecolor="yellow")
# Add plot on the image.
px = np.linspace(0,100,500)
py = 10*np.abs(np.sin(2*np.pi*0.02*px))
imgx,imgy = xy2imgxy(px,py)
ax.plot(imgx,imgy,color="yellow",lw=3)
# Adjust the axis.
ax.set_xlim(0,tickpx.max())
ax.set_ylim(tickpy.max(),0)
# Save figure.
plt.savefig("lena_color_mod.png",bbox_inches="tight",pad_inches=0.02,dpi=250)
plt.show()