啊!實際上,linestyle='dashed'
確實有效,只是箭頭只在默認情況下被填充,沒有線寬設置。他們是補丁而不是路徑。
如果你做這樣的事情:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis('equal')
ax.quiver((0,0), (0,0), (3,1), (1,0), angles='xy', scale_units='xy', scale=1,
linestyle='dashed', facecolor='none', linewidth=1)
ax.axis([-4, 4, -4, 4])
plt.show()
你得到虛線箭頭,但可能並不完全符合你腦子裏。
可以玩弄一些參數變得有點接近,但它仍然不是完全好看:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis('equal')
ax.quiver((0,0), (0,0), (3,1), (1,0), angles='xy', scale_units='xy', scale=1,
linestyle='dashed', facecolor='none', linewidth=2,
width=0.0001, headwidth=300, headlength=500)
ax.axis([-4, 4, -4, 4])
plt.show()
因此,另一種解決方法是使用艙口:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis('equal')
ax.quiver((0,0), (0,0), (3,1), (1,0), angles='xy', scale_units='xy', scale=1,
hatch='ooo', facecolor='none')
ax.axis([-4, 4, -4, 4])
plt.show()
'線型='dashed''應該工作,[根據文檔](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.quiver)。但顯然這不起作用。這可能是一個錯誤。 – 2013-03-12 02:46:38
@JoeKington::(對於解決方法有什麼建議嗎? – Mehrdad 2013-03-12 02:53:03
不是我的頭頂,不幸的是... – 2013-03-12 03:07:38