I'm plotting the trajectory of two particles in time and I'm using FuncAnimation
for that. Since the movement is periodic, I'd like to fade out the trajectory markers proportional to their distance in time with the current time. i.e. the ones which belong to timestamps prior to some memory M
all have alpha=0
and as we get closer to the current timestamp at each time, the alpha becomes closer to 1.
I first used plt.plot
which returns a list of 2DLine
s. The output was rather satisfactory except the fact that all the lines and their marker have the same alpha all the time since, in fact, I hadn't used any alpha varying setting.
As a second attempt, I tried to use plt.scatter
and providing a list of 4-elements tuple (3 for RGB and one for alpha) to set_color
. This also was rather satisfactory. I have this fade-out effect that I was looking for. Yet, for certain input parameters, it would be much better to have a line between every two markers. Hence, despite it works, I'd like to stick to the plt.plot
for my script.
Finally, I was wondering if there's a trick to change the alpha for each line of the 2Dline
list that is returned by plt.plot
.