How To Plot With Matplotlib A 3d Quiver Plot With Color Gradient For Length? Gives Error "ValueError: Object Too Deep For Desired Array"
I want to indicate the length of the quivers (are the arrows calls quivers?) by color coding them. That is no issue with 2d quiver plots. Here it is done. With 3d projection it fai
Solution 1:
As @venky__ pointed out, there has been discussion about similar things before. I put that into a subroutine and adjusted for arrow length, even taking into account complex numbers in my arrays.
def plot_3d_quiver(x, y, z, u, v, w):
c = np.sqrt(np.abs(v) ** 2 + np.abs(u) ** 2 + np.abs(w) ** 2)
c = (c.ravel() - c.min()) / c.ptp()
# Repeat for each body line and two head lines
c = np.concatenate((c, np.repeat(c, 2)))
# Colormap
c = plt.cm.jet(c)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.quiver(x, y, z, u, v, w, colors=c, length=0.1)
plt.show()
Post a Comment for "How To Plot With Matplotlib A 3d Quiver Plot With Color Gradient For Length? Gives Error "ValueError: Object Too Deep For Desired Array""