I have 3 lists which contain the x cordinates, y coordinates and z coordinates respectively. I am trying to track the position in 3D space. I use the below code:
fig = plt.figure()
ax = p3.Axes3D(fig)
def update(num, data, line):
line.set_data(data[:2, :num])
line.set_3d_properties(data[2, :num])
N = 4000
d3d=np.array([xdata,ydata,zdata])
line, = ax.plot(d3d[0, 0:1], d3d[1, 0:1], d3d[2, 0:1], color='blue')
ax.set_xlim3d([2.0, -2.0])
ax.set_xlabel('X')
ax.set_ylim3d([2.0, -2.0])
ax.set_ylabel('Y')
ax.set_zlim3d([0.0, 4.0])
ax.set_zlabel('Z')
ani = animation.FuncAnimation(fig, update, N, fargs=(d3d, line), interval=10000/N, blit=False)
plt.show()
With this I can successfully see the trajectory in blue color. However, I want to see the updated trajectory in blue and want to gray out he previous one:
I tried using below in update function so gray out he previous line:
def update(num, data, line):
line.set_data(data[:2, :num])
line.set_3d_properties(data[2, :num])
if line is not None:
line.set_color('gray')
but this just grays out the whole trajectory. Any help would be appreciated.