Matplotlib 波浪箭头 [英] Matplotlib Wavy Arrow

查看:34
本文介绍了Matplotlib 波浪箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问有什么办法可以在 matplotlib/python 中创建波浪形"箭头?

Is there any way to create a 'wavy' arrow in matplotlib / python please?

理想情况下,我想重新创建如下内容:

Ideally, I'd like to recreate something like the following:

推荐答案

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

To reproduce the wavy arrow from the question, you may use a line plot and a triangle

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()

这篇关于Matplotlib 波浪箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆