How do you directly overlay a scatter plot on top of a jpg image in matplotlib / Python?

The pyplot.scatter() function was tailor made for this reason:

import matplotlib.pyplot as plt
im = plt.imread(image_name)
implot = plt.imshow(im)

# put a blue dot at (10, 20)
plt.scatter([10], [20])

# put a red dot, size 40, at 2 locations:
plt.scatter(x=[30, 40], y=[50, 60], c="r", s=40)

plt.show()

See the documentation for more info.

Leave a Comment