lol*_*ter 5 python plot matplotlib
我AxesImage
在pylab中有一个Python对象.如何在情节顶部绘制点?
例如,我imshow
在一个2D数组上做了,返回了AxesImage.然后我没有找到一些峰值,发现(i, j)
对应于峰值的对.现在,我所要做的就是将它们叠加在图像上.
我认为scatter()
函数通常是你如何绘制这样的东西(?),但我无法覆盖它.
谢谢!
解决方案相当简单,但不知道您可以像这样使用 Axes 对象:
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()
Run Code Online (Sandbox Code Playgroud)
对于大多数 matplotlib 专家来说可能非常简单,但我却进行了相当多的猜测。