gpt4 book ai didi

Matplotlib 波浪箭头

转载 作者:行者123 更新时间:2023-12-01 01:49:49 24 4
gpt4 key购买 nike

请问有什么方法可以在 matplotlib/python 中创建一个“波浪”箭头吗?

理想情况下,我想重新创建如下内容: enter image description here

最佳答案

要重现问题中的波浪箭头,您可以使用线图和三角形

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.path as mpath
import matplotlib.patches as mpatches

fig, ax = plt.subplots()

x = np.linspace(0,9*np.pi,151)
y = np.sin(x)
ax.plot(x,y, color="gray", lw="3")

verts = np.array([[0,1],[0,-1],[2,0],[0,1]]).astype(float)*1.3
verts[:,0] += 9*np.pi
path = mpath.Path(verts)
patch = mpatches.PathPatch(path, fc='gray', ec="gray")
ax.add_patch(patch)

ax.axis("off")
ax.set_aspect("equal",'datalim')
ax.relim()
ax.autoscale_view()
plt.show()

enter image description here

关于Matplotlib 波浪箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45365158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com