我目前在Matplotlib中做一些"花哨"的注释:
import matplotlib.pyplot as plt ax = plt.subplot(111) plt.axis('equal') src_pos, dst_pos = (0, 0), (1, 1) src_patch = plt.Rectangle(src_pos, .25, .25, color='r') ax.add_patch(src_patch) dst_patch = plt.Circle(dst_pos, .25, color='b') ax.add_patch(dst_patch) arrowprops = dict( arrow, connection, patchA=dst_patch, patchB=src_patch, shrinkA=1, shrinkB=1) ant = ax.annotate('', src_pos, dst_pos, arrowprops=arrowprops) plt.draw() plt.show()
现在我想在箭头旁边添加一些文字.输出应如下所示:
我对一般解决方案感兴趣,其中文本放置是根据渲染器选择的箭头路径以编程方式选择的.例如,
文本应适当放置的未知值src_pos
和dst_pos
.
无论如何arrowprops
设置和使用哪个文本,都应该适当放置文本connectionstyle
.
我宁愿plt.draw()
在剧本结束之前不必打电话.
谢谢!