ggplotを使ったアニメーションがplotlyで紹介されていました。
こちらの記事をみて、animationするplotをかけるようなので、書いてみました。開発中みたいなので、今後内容は代わるかもしれません。
先に、devtoolsやplotlyのinstallが必要なのでお済みでない方は、
こちらをみてinstallしておいてください
plotly_animation}
# けっこう時間がかかる
devtools::install_github("ropensci/plotly#554")
install.packages("gapminder")
# libraryとデータの読み込み
library(plotly)
data(gapminder, package = "gapminder")
# 作図オブジェクト作成
gg <- ggplot(gapminder, aes(gdpPercap, lifeExp)) +
geom_point(aes(size = pop, color = continent, frame = year, ids = country)) +
scale_x_log10()
# 警告: Ignoring unknown aesthetics: frame, ids
# ☝️warningがでてるよお兄さん
# 作図
ggplotly(gg)
スクリーンショットで恐縮ですがちゃんと動きました!! presentationに使えそうですね、自分の時系列データを動かしてみたいです。