Попытка применить не-функцию, когда view_follow () используется в ggplot2 - PullRequest
1 голос
/ 25 апреля 2020

Получение «попытки применить не-функцию» при использовании view_follow (). Он работает, как и ожидалось, когда функция view_follow () удалена. Я добавляю это, чтобы отрегулировать основание оси Y для значения, нанесенного на ось. Я ценю помощь.

Воспроизводимый код приведен ниже:

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)}")

1 Ответ

0 голосов
/ 26 апреля 2020

Ниже работает код: решение найдено @ https://github.com/thomasp85/gganimate/issues/304

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)}")

Спасибо

...