gpt4 book ai didi

r - 保持点在gganimate

转载 作者:行者123 更新时间:2023-12-01 11:15:16 24 4
gpt4 key购买 nike

我想使用 gganimate 记录测试情况下的进度:
我已经走了这么远:

library(tidyverse)
library(gganimate)

data <- tribble(~user, ~agree, ~accord, ~messung,
"1", .8, .9, 1,
"2",.7, .8, 1,
"3", .6, .9, 1)
data2 <- tribble(~user, ~agree2, ~accord2, ~messung2,
"1", .4, .7, 2,
"2", .5, .9, 2,
"3", .9, .9, 2)

data%>%
left_join(data2)%>%
mutate(user = as.numeric(user))%>%
ggplot(aes(x = accord, y = agree))+
geom_point(aes(fill = "grey"), color = "grey", size = 2)+
geom_point(aes(x = accord2, y = agree2), color = "green",
size = 2)+
xlim(0,1)+
ylim(0,1)+
geom_segment(aes(x = accord,
y = agree,
xend = accord2,
yend = agree2),
size = 0.5, arrow = arrow(type="closed", length =
unit(.08, "inches"), angle = 30),
color = "grey")+
theme_minimal()+
guides(fill=FALSE, color=FALSE)+
transition_manual(user)

起初,颜色和表现是次要的。学习如何将点一个接一个地制作动画而不会使之前的点再次消失很重要吗?
欢迎任何帮助!谢谢

最佳答案

我无法使用 transition_manual 使其工作,但您可以使用 transition_states 获得所需的输出。如果你不想过渡,你可以将 transition_length 设置为零。

data%>%
left_join(data2)%>%
mutate(user = as.numeric(user)) %>%

ggplot() +
geom_point(aes(x = accord, y = agree), color = "grey", size = 2, fill = "grey") +
geom_point(aes(x = accord2, y = agree2), color = "green", size = 2)+
xlim(0,1)+ ylim(0,1)+
geom_segment(aes(x = accord, y = agree, xend = accord2, yend = agree2),
size = 0.5, color = "grey",
arrow = arrow(type="closed", length = unit(.08, "inches"), angle = 30))+
theme_minimal() +
# Use zero for "transition_length" to remove animation easing altogether
transition_states(user, transition_length = 1, state_length = 2) +
# shadow_mark(exclude_layer = 3) # This hides the arrow from animating
shadow_mark()

enter image description here

关于r - 保持点在gganimate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52614197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com