Python matplotlib-移动文本批注
如何在已创建文本批注后移动它?例如,在循环中创建了一组文本注释之后,我想返回并移动其中一个位置,在脚本中,但不在循环中。在下面的代码中,我想将1.9注释移到行的上方。谢谢Python matplotlib-移动文本批注,python,matplotlib,Python,Matplotlib,如何在已创建文本批注后移动它?例如,在循环中创建了一组文本注释之后,我想返回并移动其中一个位置,在脚本中,但不在循环中。在下面的代码中,我想将1.9注释移到行的上方。谢谢 import matplotlib.pyplot as plt ax = plt.axes() x = [0, 1, 1.8, 1.9, 3, 4] y = [0, 1, 1.8, 1.9, 3, 4] ax.plot(x,y) for ii in range(0,len(x)): plt.text(x[ii],
import matplotlib.pyplot as plt
ax = plt.axes()
x = [0, 1, 1.8, 1.9, 3, 4]
y = [0, 1, 1.8, 1.9, 3, 4]
ax.plot(x,y)
for ii in range(0,len(x)):
plt.text(x[ii], y[ii]-.15, x[ii], fontsize=25)
你可以试试这个
import matplotlib.pyplot as plt
ax = plt.axes()
x = [0, 1, 1.8, 1.9, 3, 4]
y = [0, 1, 1.8, 1.9, 3, 4]
ax.plot(x,y)
txt = []
for ii in range(0,len(x)):
txt.append(plt.text(x[ii], y[ii]-.15, x[ii], fontsize=25))
txt[3].set_x(1.3)
plt.show()
为什么不能将创建的
文本存储在数组中,然后进行更新。