我有三个列表,一个包含一组名为“Atype”的符号(字符),第二个列表“el”包含一组数字,每个对应于“Atype”中元素的位置+1,另一个列表包含一组名为“XYcoord”的坐标(x,y)。我想在绘图中注释AType的字符,将AType的每个元素放在XYCoord中对应的(x,y)对所指示的位置(在绘图上)。这不是问题,但我想在两点之间的距离小于值“BMax”时在字母之间画一条连接线。
到目前为止,我得到的是:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
for x in range(1, NCenter+1): # NCenter is the number of elements in AType and XYcoord.
xposcoord, yposcoord = XYcoord[x-1][0]/100.0, XYcoord[x-1][1]/100.0
ax.annotate('%s' % (AType[el[x-1]-1]), xy=(xposcoord, yposcoord),
xycoords='axes fraction')
plt.show()
我得到一个情节是: 现在,我想在字母之间画一条连接线,如果它们之间的距离小于BMax。我以前定义了一个函数,它返回点之间的距离“dist_betwn_points(x1,y1,x2,y2)”,因此,我通过在某处放置if语句来知道,例如:
^{pr2}$会有帮助,但我尝试了几种方法,但都没有成功地定义“ax.注释(…)“部分,在字母之间画线。 谢谢你的帮助!在
这里有一个例子。我希望这对你有帮助。在
相关问题 更多 >
编程相关推荐