Reputation: 59
How can I use two different linestyle in a quiver plot? I tried the same procedure as color, but it does not work. I send my code and the result.
import numpy as np
import matplotlib.pyplot as plt
V = array([[-8.51111054e-01, -2.07125731e-02],
[ 1.00514114e+00, 1.45925842e-02],
[-9.20205414e-01, -8.90733267e-04],
[-5.49162030e-01, -5.72392077e-04],
[-3.20711851e-01, 1.04597686e-02],
[ 7.85996497e-01, 1.78952999e-02]])
And now plot the vectors with origin at (0,0)
plt.figure()
plt.quiver([0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], V.T[0,:], V.T[1,:], angles='xy', scale_units='xy',
color=['b','b','r','r','k','k'],
linestyle=('-','--','-','--','-','--'), scale=1)
plt.xlim(-1.5, 1.7)
plt.ylim(b.min()*1.2,b.max()*1.2)
plt.show()
Upvotes: 1
Views: 2100
Reputation: 62393
matplotlib.pyplot.quiver
linestyle
works, which refers to the edges.
linewidth
is small, the edges aren't visible.color
is the facecolor, and obscures the edges. Use edgecolor
or ec
.import matplotlib.pyplot as plt
plt.figure(figsize=(10, 10))
color=['b','b','r','r','k','k']
plt.quiver([0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], V.T[0,:], V.T[1,:], angles='xy', scale_units='xy',
ls=['solid','dashed','-.',':','-','--'], scale=1, linewidth=1, fc='none', ec=color)
plt.xlim(-1.5, 1.7)
plt.show()
ec
to black and then use facecolor, but it's difficult to see.plt.figure(figsize=(10, 10))
color=['g','g','r','r','orange','orange']
plt.quiver([0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], V.T[0,:], V.T[1,:], angles='xy', scale_units='xy',
color=color,
ls=['solid','dashed','-.',':','-','--'], scale=1, linewidth=2, edgecolor='k')
plt.xlim(-1.5, 1.7)
plt.show()
Upvotes: 2