を使用して gif を作成したいのですgganimate
が、軸の範囲が 1 つのフレーム内で大きく異なります。これにより、後続のすべてのフレームがスクイーズされます。
のファセットにはggplot2
、 を持つオプションがありますscales="free"
。の各フレームにフリースケールを設定する方法はありgganimate
ますか?
次に例を示します。
library(gapminder)
library(ggplot2)
library(gganimate)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent,
frame = year)) +
geom_point() +
scale_x_log10()
gganimate(p)
ここで、データ ポイントの 1 つを極端な値に移動します。これにより、影響を受けない後続のすべてのフレームのポイントが圧迫されます。
gapminder[1, "lifeExp"] <- 1000
gapminder[1, "gdpPercap"] <- 1e60
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent,
frame = year)) +
geom_point() +
scale_x_log10()
gganimate(p) # smooshed