0

As stated in the tittle, I'm trying to make a 2D representation of moving markers on a delimited area. The [id,posx,posy,posz,time] is obtained from a SQL database and the theoretical frequency of the hardware is 10Hz.

When applying the animation function animate() as it follows

anim = FuncAnimation(fig, animate, interval = 100, repeat = False)

I found that, while printing both markers correctly in sequence of arrival, real time was not properly represented (it was almost a 1:2 relation of represented time vs real time).

On the other hand, I found an answer from stackoverflow with the following code to solve this time representation issue:

frame_t = []
for i, t in enumerate(res):
    if i < len(res)-1:
        diff = (res[i+1][4] - res[i][4]).total_seconds()
        frame_t.extend([[i]] * int(round(diff/0.1, 0)))

#animate function

anim = FuncAnimation(fig, animate, frames = frame_t, interval = 100, repeat = False)

and while it solves the issue and the representation is properly adjusted in time for one single point, when a second one enters into the plot it starts to omit frames from one or the other.

I've found that this is represented in frames_t with omission or duplication of incoming frames (e.g. [...,13,14,14,15,17,18,...]) and that passing a regular array is equivalent to the previous non frame specified FuncAnimantion parametrization.

Is there any way of solving both issues at the same time? I don't mind changing to other library if I can get it done easier that way.

For a visual example, this is a plot screenshot during the animation

enter image description here

enter image description here

Here is an anonymized version of the code: https://gist.github.com/jelexpuru/5b14e0cf90945f29002174eda0ba8b31 And a sample of the query obtained to be animated: https://gist.github.com/jelexpuru/3760ad8dcf153153901c6b4febd2946b

Thx very much

Julen
  • 97
  • 2
  • 9

0 Answers0