I have a an AxesImage
object in Python from pylab. How do I plot points on top of the plot?
For example, I did imshow
on a 2D array that I have, returning the AxesImage. Then I didn some peak finding and found (i, j)
pairs which correspond to the peaks. Now all I have to do is overlay them on top of the image.
I think the scatter()
function is normally how you plot something like this (?) but I couldn't get it to overlay.
Thanks!
Solution was fairly simple, but wasn't aware you could use Axes objects like this:
import matplotlib.pyplot as plt
# detect peaks somehow
i, j = detect_peaks(array2d)
# plot
fig, ax = plt.subplots()
ax.imshow(array2d)
ax.scatter(i, j)
plt.show()
Probably very simple for most matplotlib experts, but took quite a bit of guesswork on my part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With