我想做这样的图:
但我不知道如何创建其中包含文本的圆圈。
我希望圆根据窗口而不是轴放置。我发现的所有示例都是根据轴的坐标放置圆的,但我希望在窗口上有一个坐标基础。例如 X 方向为 0.2,Y 方向为 0.9
现在我有这个代码:
import matplotlib.pyplot as plt
import numpy as np
t=np.arange(0,10,0.01)
y1=np.sin(2*3.14*10*t)
plt.figure(1)
plt.subplots_adjust(hspace=0.01)
plt.subplot(211)
plt.plot(t,y1)
# create the circle with black border and grey fill, and the text 1 in it
plt.show()
创建注释或文本的众多选项中的三个在图形坐标中:
-
指定xycoords
的论证annotate https://matplotlib.org/users/annotations.html#basic-annotation:
plt.annotate("1",(0.2,0.9), xycoords="figure fraction",
bbox={"boxstyle" : "circle", "color":"grey"})
-
Use figtext https://matplotlib.org/api/_as_gen/matplotlib.pyplot.figtext.html创建您的文本。
plt.figtext(0.2,0.9,"1",
bbox={"boxstyle" : "circle", "color":"grey"})
-
指定通常使用的变换text https://matplotlib.org/api/text_api.html#matplotlib.text.Text:
plt.text(0.2,0.9,"1", transform=plt.gcf().transFigure,
bbox={"boxstyle" : "circle", "color":"grey"})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)