python - 在图像中绘制标记

标签 python image matplotlib

我正在使用 Matplotlib 绘制图片:

plt.imshow(bild)
plt.show()

如何使用图像的坐标为其添加标记(例如红点/箭头)?

最佳答案

您还可以使用 plt.scatter添加一个红点来标记该点。基于上一个答案的示例代码:

import matplotlib.pyplot as plt
import numpy as np

img = np.random.randn(100, 100)

plt.figure()
plt.imshow(img)
plt.annotate('25, 50', xy=(25, 50), xycoords='data',
             xytext=(0.5, 0.5), textcoords='figure fraction',
             arrowprops=dict(arrowstyle="->"))
plt.scatter(25, 50, s=500, c='red', marker='o')
plt.show()

关于python - 在图像中绘制标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32551536/

相关文章:

python - 如何让 FigureCanvasTkAgg 与 Scrollbar 一起工作

python - 为什么我不能在 Pandas 系列生成的绘图上设置 y 轴范围?

python - 可以在 Django View 中使用 Python 生成器吗?

python - 使用 numpy 稀疏数组优化操作

jquery - 设置从 JQUERY/FLICKR API 提取的缩略图图像的自定义大小

python - 使用 matplotlib 库绘制列表(不按顺序)时如何纠正 y 间隔?

python - Matplotlib lib 以第四维为颜色的 3d 曲面图

python - dir() 内置函数返回 "(some of) the attributes of the given object"是什么意思?

css - 样式 CSS 不使用 CodeIgniter - Baseurl

ios - CALayer 上的图像在缩小然后再次放大后变得模糊