更改matplotlib quiver函数的箭头样式

更改matplotlib quiver函数的箭头样式,matplotlib,Matplotlib,有没有办法改变箭头的样式 我尝试将arrowprops=dict()kwarg传递给函数,但这似乎只适用于 在任何情况下,我正在寻找的箭头样式似乎都不包含在matplotlib中。我认为它们被称为“半箭”。我可以使用UTF-8字符插入这些箭头,但是这些箭头无法自定义,很难正确对齐。是否有更好的方法(可能是插入SVG符号) 上面我的解决方案的代码: import matplotlib.pyplot as plt import numpy as np import mplstereonet imp

有没有办法改变箭头的样式

我尝试将
arrowprops=dict()
kwarg传递给函数,但这似乎只适用于

在任何情况下,我正在寻找的箭头样式似乎都不包含在matplotlib中。我认为它们被称为“半箭”。我可以使用UTF-8字符插入这些箭头,但是这些箭头无法自定义,很难正确对齐。是否有更好的方法(可能是插入SVG符号)

上面我的解决方案的代码:

import matplotlib.pyplot as plt
import numpy as np
import mplstereonet
import matplotlib.image as image

#UTF-8 characters don't seem to work in the normal pyplot backend
plt.switch_backend("gtk3cairo")

fig = plt.figure()
ax = fig.add_subplot(111, projection='stereonet')

arrows = [[120, 30, 120, 30, "sin"],
          [160, 50, 160, 50, "dex"]]

for arrow in arrows:
    strike = arrow[0] - 90
    ax.plane(strike, arrow[1], color="#000000")
    ax.line(arrow[3], arrow[2], color="#ff0000")

    x, y = mplstereonet.line(arrow[3], arrow[2])
    ang = np.degrees(np.arctan2(x, y))[0] * (-1)
    gap = 0.08
    gap_x = gap * np.sin(ang)
    gap_y = gap * np.cos(ang)

    if arrow[4] == "dex":
        ax.text(x - gap_x, y - gap_y, "⇀", size=30, rotation=ang,
                horizontalalignment="center", verticalalignment="center")
        ax.text(x + gap_x, y + gap_y, "↽", size=30, rotation=ang,
                horizontalalignment="center", verticalalignment="center")

    elif arrow[4] == "sin":
        ax.text(x - gap_x, y - gap_y, "↼", size=30, rotation=ang,
                horizontalalignment="center", verticalalignment="center")
        ax.text(x + gap_x, y + gap_y, "⇁", size=30, rotation=ang,
                horizontalalignment="center", verticalalignment="center")

plt.show()
类似问题:


注意:关于
arrowprops=dict()的使用,这只是部分回答


问题的一部分在于,有7位(!)艺术家可以用来绘制箭头(Arrow、FancyRow、FancyRowPatch、ConnectionPatch、YAArrow、SimpleRow(FancyRowPatch的一个子类)和Filled Arrow),所有这些艺术家的行为不同,界面也不同

这不包括绘制箭头的quiver,但它是一个多集合子类

您可以阅读有关此讨论的更多信息

还提到,一些函数会根据给定的参数自动更改箭头样式:

[…]annotate函数的问题在于,用户不清楚API在指定不同的箭头样式时会发生变化

我在
注释
中遇到了类似的问题,您可以看到