python中画两点间的曲线(曲线箭头)
如果想要在python中画两点间的曲线或是带箭头的曲线可以⽤下⾯的⽅式来画:
1.带箭头的曲线
import matplotlib.pyplot as plt
plt.figure(figsize=(3.2, 2))
ax = plt.subplot(1,1,1)
ax.annotate("",
xy=(0.2, 0.2),
xytext=(0.8, 0.8),
size=20, va="center", ha="center",
arrowprops=dict(color='#373331',
arrow,
connection,
)
)
plt.show()
关键参数:
xytext=(0.8, 0.8) 中设置曲线的起点
xy=(0.2, 0.2) 中设置曲线的终点
connection  rad 可以改变直线的曲率,可以根据⾃⼰的需要调整,添加负号可以修改曲线弯的⽅向。
2.两点间曲线
import matplotlib.pyplot as plt
plt.figure(figsize=(3.2, 2))
ax = plt.subplot(1,1,1)
ax.annotate("",
xy=(0.2, 0.2),
xytext=(0.8, 0.8),
size=20, va="center", ha="center",
arrowprops=dict(color='#373331',
arrow,
connection,                            linewidth=5
)
)
plt.show()
关键参数:
arrowstyle=‘-’  ⽆箭头形式
linewidth  可以设置线宽
matplotlib中subplot