Saturday, 17 April 2021

How to animate a 2D scatter plot given X, Y coordinates and time with appearing and disappearing points?

I have a data frame like the below: enter image description here

Every row represents a person. They stay at 3 different locations for some time given on the dataframe. The first few people don't stay at location1 but they "born" at location2. The rest of them stay at every locations (3 locations).

I would like to animate every person at the given X, Y coordinates given on the data frame and represent them as dots or any other shape. Here is the flow:

  1. Every person should appear at the first given location (location1) at the given time. Their color should be blue at this state.
  2. Stay at location1 until location2_time and then appear at location2. Their color should be red at this state.
  3. Stay at location2 until location3_time and then appear at location3. Their color should be red at this state.
  4. Stay at location3 for 3 seconds and disappear forever.

There can be several people on the visual at the same time. How can I do that?

There are some good answers on the below links. However, on these solutions, points don't disappear.

  1. How can i make points of a python plot appear over time?
  2. How to animate a scatter plot?


from How to animate a 2D scatter plot given X, Y coordinates and time with appearing and disappearing points?

No comments:

Post a Comment