小编Rah*_*Rah的帖子

将文本锚定或锁定到 Matplotlib 中的标记

有什么方法可以将文本锚定或锁定到标记吗?当使用 提供的交互式缩放时pyplot,文本会超出范围,如图所示。

import matplotlib.pyplot as plt

x=[2,4]
y=[2,3]

fig, ax = plt.subplots()
ax.plot(x, y, 'ro',markersize=23)

offset = 1.0 
ax.set_xlim(min(x)-offset, max(x)+ offset)
ax.set_ylim(min(y)-offset, max(y)+ offset)

for x,y in zip(x,y):
     ax.annotate(str(y),  xy=(x-0.028,y-0.028))

plt.show()
Run Code Online (Sandbox Code Playgroud)

文字超出范围

python text annotate matplotlib marker

5
推荐指数
1
解决办法
2611
查看次数

为 pyplot.plot() 寻找标记文本选项

我正在寻找一种将数字或文本插入标记的方法。matplotlib.pyplot.plot(*args, **kwargs)文档中没有关于这一点的内容。

默认缩放级别将标记放置在边缘上,从而减少了用于刻录文本的可用空间。

import matplotlib.pyplot as plt
x = [1, 2, 3, 4 ,5]
y = [1, 4, 9, 6, 10]
plt.plot(x, y, 'ro',markersize=23)
plt.show()
Run Code Online (Sandbox Code Playgroud)

python plot text matplotlib markers

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

matplotlib ×2

python ×2

text ×2

annotate ×1

marker ×1

markers ×1

plot ×1