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

用户3456588

我正在尝试将自己的图像用于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 = 100)

用上传的图片替换geom_point

史蒂夫·李

这是您要找的东西吗?

我只是将color = factor(Name)立场改为geom_line陈述。

如果在第一行中使用color = factor(Name)with ggplot,它将影响整个图。因此,使用此语句时应格外小心。

a <- ggplot(Final, aes(x = Step, y = Value, group = Name)) + 
  geom_line(size=1, aes(color = factor(Name))) + 
  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") 

为了方便起见,我拍摄了这张照片。

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在geom_point ggplot中删除点组

来自分类Dev

在geom_point中使用cut时如何在ggplot中添加椭圆

来自分类Dev

如何在R中使用ggplot2根据大小为节点/ geom_point渐变着色?

来自分类Dev

在ggplot / gganimate中控制geom_point和geom_text的颜色

来自分类Dev

将gganimate与geom_point和geom_line一起使用

来自分类Dev

将自定义图像显示为geom_point

来自分类Dev

如何在具有多个geom_point图层的图中为图例设置样式和位置?

来自分类Dev

使用R中的geom_point将点大小调整为单个变量

来自分类Dev

R中的Geom_text()-如何更改geom_point中特定点的标签位置

来自分类Dev

如果r中的值小于0或大于0,如何根据条件为geom_line()和geom_point()正确着色?

来自分类Dev

如何更改 geom_point 外观?

来自分类Dev

为ggplot2中的负值和正值在geom_point中设置不同的颜色

来自分类Dev

使用geom_bar和geom_point控制ggplot中的图例

来自分类Dev

使用geom_point()和geom_line()进行多个系列的ggplot中的图例错误

来自分类Dev

为ggplot2中的两个geom_point()更改颜色

来自分类Dev

使用 geom_point 时出现错误“geom_point 需要以下缺失的美学:y”

来自分类Dev

使用geom_point有条件地使用ggplot2中的抖动

来自分类Dev

Geom_point将点设置为错误的值

来自分类Dev

为ggplot在geom_point上订购颜色

来自分类Dev

Geom_point将点设置为错误的值

来自分类Dev

如何更改ggplot2的geom_point中缺失值的颜色?

来自分类Dev

如何更改ggplot2的geom_point中缺失值的颜色?

来自分类Dev

无论如何要更改 R (geom_point) 中 ggplot 中值的大小?

来自分类Dev

您如何在Rebol中定义自己的数据类型?

来自分类Dev

R:如何使用geom_point将点添加到并排错误栏

来自分类Dev

使用aes_string时,ggplot2中两个geom_point()的颜色

来自分类Dev

避免在ggplot2中使用geom_point进行图覆盖

来自分类Dev

如何在geom_boxplot中定义自己的陷波间隔?

来自分类Dev

在一个图中使用geom_point和geom_pointrange时如何维护因子顺序?

Related 相关文章

  1. 1

    如何在geom_point ggplot中删除点组

  2. 2

    在geom_point中使用cut时如何在ggplot中添加椭圆

  3. 3

    如何在R中使用ggplot2根据大小为节点/ geom_point渐变着色?

  4. 4

    在ggplot / gganimate中控制geom_point和geom_text的颜色

  5. 5

    将gganimate与geom_point和geom_line一起使用

  6. 6

    将自定义图像显示为geom_point

  7. 7

    如何在具有多个geom_point图层的图中为图例设置样式和位置?

  8. 8

    使用R中的geom_point将点大小调整为单个变量

  9. 9

    R中的Geom_text()-如何更改geom_point中特定点的标签位置

  10. 10

    如果r中的值小于0或大于0,如何根据条件为geom_line()和geom_point()正确着色?

  11. 11

    如何更改 geom_point 外观?

  12. 12

    为ggplot2中的负值和正值在geom_point中设置不同的颜色

  13. 13

    使用geom_bar和geom_point控制ggplot中的图例

  14. 14

    使用geom_point()和geom_line()进行多个系列的ggplot中的图例错误

  15. 15

    为ggplot2中的两个geom_point()更改颜色

  16. 16

    使用 geom_point 时出现错误“geom_point 需要以下缺失的美学:y”

  17. 17

    使用geom_point有条件地使用ggplot2中的抖动

  18. 18

    Geom_point将点设置为错误的值

  19. 19

    为ggplot在geom_point上订购颜色

  20. 20

    Geom_point将点设置为错误的值

  21. 21

    如何更改ggplot2的geom_point中缺失值的颜色?

  22. 22

    如何更改ggplot2的geom_point中缺失值的颜色?

  23. 23

    无论如何要更改 R (geom_point) 中 ggplot 中值的大小?

  24. 24

    您如何在Rebol中定义自己的数据类型?

  25. 25

    R:如何使用geom_point将点添加到并排错误栏

  26. 26

    使用aes_string时,ggplot2中两个geom_point()的颜色

  27. 27

    避免在ggplot2中使用geom_point进行图覆盖

  28. 28

    如何在geom_boxplot中定义自己的陷波间隔?

  29. 29

    在一个图中使用geom_point和geom_pointrange时如何维护因子顺序?

热门标签

归档