有没有办法改变matplotlib quiver function的箭头样式?
我尝试将arrowprops=dict()
kwarg传递给函数,但这似乎只适用于annotate function。
无论如何我正在寻找的箭头样式似乎不包含在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()
类似的问题: