I m trying to create animation to show transition along some nodes. I want to show point moving from SRC to TGT with transition change in intensity my df is like this below.
> df
node intensity Lon Lat
1 SRC 0.90 40 60
2 TGT 0.89 80 40
3 TGT 0.80 40 30
4 TGT 0.99 30 20
library(ggplot2)
library(gganimate)
df <- read.table(text = "node intensity Lon Lat
SRC .9 40 60
TGT .89 80 40
TGT .8 40 30
TGT .99 30 20", header = TRUE)
ggm <- ggplot(data = df, aes(x = Lon, y = Lat, size= intensity, colour=node)) +
geom_point(alpha=.5)+
transition_states(node)+
labs(title = "test")+
shadow_wake(wake_length = 0.5)
my desired output is to show moving animation something like this
I am getting point stationary SRC and TGT along frames
You can get the desired effect by making three copies of the source and assigning a group to each point that should go from its source to target location.
https://cran.r-project.org/web/packages/gganimate/vignettes/gganimate.html
The key is the group aesthetic. You may be familiar with this
aesthetic from plotting lines and polygons, but in gganimate it takes
a more central place. Data that have the same group aesthetic are
interpreted as being linked across states. The semantics of the group
aesthetic in ggplot2 is such that if it is undefined it will get
calculated based on the interaction of all discrete aesthetics (sans
label). If none exists, such as in our iris animation, all data will
get the same group, and will thus be matched by gganimate.
library(ggplot2)
library(gganimate)
df <- read.table(text = "node intensity Lon Lat grp
SRC .9 40 60 1
SRC .9 40 60 2
SRC .9 40 60 3
TGT .89 80 40 1
TGT .8 40 30 2
TGT .99 30 20 3", header = TRUE)
ggm <- ggplot(data = df, aes(x = Lon, y = Lat, size= intensity, colour=node, group = grp)) +
geom_point(alpha=.5)+
transition_states(node)+
labs(title = "test")+
shadow_wake(wake_length = 0.5)