R 在ggplot2中使用view_follow()时尝试应用非函数
使用view_follow()时获取“尝试应用非函数”。当view_follow()函数被删除时,它将按预期工作。我添加此项是为了根据轴上绘制的值调整y轴基准。谢谢你的帮助 可复制代码如下所示:R 在ggplot2中使用view_follow()时尝试应用非函数,r,ggplot2,gganimate,R,Ggplot2,Gganimate,使用view_follow()时获取“尝试应用非函数”。当view_follow()函数被删除时,它将按预期工作。我添加此项是为了根据轴上绘制的值调整y轴基准。谢谢你的帮助 可复制代码如下所示: library(plyr) library(dplyr) library(ggplot2) library(reshape) library(reshape2) library(gganimate) samplelData <- rbind( cbind.data
library(plyr)
library(dplyr)
library(ggplot2)
library(reshape)
library(reshape2)
library(gganimate)
samplelData <-
rbind(
cbind.data.frame(
year = as.integer(seq(from=2001,to=2020,by=1)),
Country = c('A'),
value = c(1:20)
),
cbind.data.frame(
year = as.integer(seq(from=2001,to=2020,by=1)),
Country = c('B'),
value = seq(from=10,to=400,by=20)
))
ggplot(samplelData,
aes(
x = Country,
y = value,
fill = Country,
frame = year
)) + geom_point(stat = 'identity', position = 'dodge') +
transition_reveal(year) + view_follow(fixed_x = TRUE) + labs(title = "Year: {round(frame_along, 0)}")
库(plyr)
图书馆(dplyr)
图书馆(GG2)
图书馆(重塑)
图书馆(E2)
库(gganimate)
samplelData以下代码有效:
找到解决方案@
谢谢以下代码有效:
找到解决方案@
多谢各位
ggplot(samplelData,
aes(
x = as.numeric(as.factor(Country)),
y = value,
fill = Country,
frame = year
)) + geom_bar(stat = 'identity', position = 'dodge') + scale_x_continuous(breaks = 1:2, labels = unique(samplelData$Country)) +
transition_reveal(year) + view_follow(fixed_x = T, fixed_y = F) + labs(title = "Year: {round(frame_along, 0)}")