python中画两点间的曲线(曲线箭头) |
您所在的位置:网站首页 › python画两条曲线怎么画 › 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', arrowstyle="simple", connectionstyle="arc3,rad=0.4", ) ) plt.show()关键参数: xytext=(0.8, 0.8) 中设置曲线的起点 xy=(0.2, 0.2) 中设置曲线的终点 connectionstyle="arc3,rad=0.4" 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', arrowstyle="-", connectionstyle="arc3,rad=0.4", linewidth=5 ) ) plt.show()关键参数: arrowstyle=‘-’ 无箭头形式 linewidth 可以设置线宽
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |