Search code examples
pythonmatplotlib3d

python matplotlib 3d quiver not showing


I am trying to plot a quiver using matplotlib in python. The quiver should appear when going going from top to bottom at the origin.

When I run the code, the plot shows up, but there is no quiver.

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(3,3))
ax = fig.add_subplot(111,projection='3d')
ax.quiver(0,0,1,0,0,0)
plt.show()

Using python 3.12.2 and matplotlib 3.1.2


Solution

  • My arguments were inputted incorrectly. The arguments should be (x,y,z,dx,dy,dz) not (x1,y1,z1,x2,y2,z2). I was drawing a 0-length vector.

    Source: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.quiver.html