小编use*_*588的帖子

Speed Up gganimate Rendering

I am currently creating a gif which contains large data. I want it in high resolution.

On my old PC it took hours to render and simply wasn't worth it.

My new PC has a very strong intel i9-9900k core processor which has sped it up to about 30 minutes but R only uses 1 core by default... I have 8 available and it would be great if I could just use them to get the rendering done in under …

multithreading r ggplot2 rstudio gganimate

8
推荐指数
1
解决办法
184
查看次数

如何使用 gganimate 动画让 x 轴跨度移动?

使用 R,我尝试使用 gganimate 制作一个基于 x 轴从左到右显示的折线图。我已经设法做到了这一点,但我还想做的是使scale_x_continuous(limits = c(i-5,i+5)),即在正在显示的点和窗口周围有一个窗口将继续前进,同时揭示下一点。

我尝试了很多方法来实现这一点,包括在带有和不带有 aes() 的scale_x_continuous 中实现某种循环。似乎什么都不起作用。我对 ggplot2 特别是 gganimate 很陌生,但我在网上找不到任何帮助。我有一种感觉,答案可能很简单,但我只是错过了。

有点像这样,但使用 gganimate:

类似的例子,但不是 gganimate

以下是一些可重现的代码,向您大致展示我到目前为止所做的事情。

library(ggplot2)
library(gganimate)
library(gifski)
library(png)


Step  <- c(1:50,1:50)
Name  <- c(rep("A",50), rep("B",50))
Value <- c(runif(50,0,10), runif(50,10,20))
Final <- data.frame(Step, Name, Value)

a <- ggplot(Final, aes(x = Step, y = Value, group = Name, color = factor(Name))) + 
 geom_line(size=1) + 
 geom_point(size = 2) + 
 transition_reveal(Step) + 
 coord_cartesian(clip = 'off') + 
 theme_minimal() +
 theme(plot.margin = margin(5.5, 40, 5.5, 5.5)) +
 theme(legend.position = "none") 

options(gganimate.dev_args …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 gganimate

6
推荐指数
1
解决办法
1564
查看次数

如何在gganimate中为geom_point使用您自己的图像?

我正在尝试将我自己的图像用于geom_point,我可以读取这些内容。我知道geom_point允许您通过简单地编写shape = 243来选择许多形状(超过300种),但是我想要我自己的图像(例如徽标)。

当我没有指定color = factor(Name)时,它可以按预期工作。当我确实指定线条的颜色时,图像将变为纯色。我希望这条线是彩色的,所以有什么办法解决吗?谢谢!

library(gganimate)
library(gifski)
library(png)
library(ggimage)


Step  <- 1:50
Name  <- rep("A",50)
Image <- rep(c("https://jeroenooms.github.io/images/frink.png"),50)
Value <- runif(50,0,10)
Final <- data.frame(Step, Name, Value, Image)

a <- ggplot(Final, aes(x = Step, y = Value, group = Name, color = factor(Name))) + 
  geom_line(size=1) + 
  geom_image(aes(image=Image)) +
  transition_reveal(Step) + 
  coord_cartesian(clip = 'off') + 
  theme_minimal() +
  theme(plot.margin = margin(5.5, 40, 5.5, 5.5)) +
  theme(legend.position = "none") 

options(gganimate.dev_args = list(width = 7, height = 6, units = 'in', res=100))
animate(a, nframes …
Run Code Online (Sandbox Code Playgroud)

animation r image ggplot2 gganimate

6
推荐指数
1
解决办法
60
查看次数

标签 统计

gganimate ×3

ggplot2 ×3

r ×3

animation ×1

image ×1

multithreading ×1

rstudio ×1