R ggimage:来自计算机而非web的自定义图像

R ggimage:来自计算机而非web的自定义图像,r,ggplot2,ggimage,R,Ggplot2,Ggimage,下图可以由下面给出的R代码生成。图表中使用的图像是从网站获取的。我想知道如何使用计算机上的图像 库(“ggplot2”) 图书馆(“ggimage”) 结实种子(2017-02-21) d非常简单,您只需设置保存要使用的.png文件的目录: library("ggplot2") library("ggimage") set.seed(2017-02-21) d <- data.frame(x = rnorm(10), y = rnorm(10),

下图可以由下面给出的R代码生成。图表中使用的图像是从网站获取的。我想知道如何使用计算机上的图像

库(“ggplot2”)
图书馆(“ggimage”)
结实种子(2017-02-21)

d非常简单,您只需设置保存要使用的.png文件的目录:

library("ggplot2")
library("ggimage")
set.seed(2017-02-21)
d <- data.frame(x = rnorm(10),
                y = rnorm(10),
                image = sample(c("C:/YourDirectory/juventus.png",
                                 "C:/YourDirectory/sampdoria.png"),
                               size=10, replace = TRUE)
)

ggplot(d, aes(x, y)) + geom_image(aes(image=image), size=.05)
库(“ggplot2”)
图书馆(“ggimage”)
结实种子(2017-02-21)

d感谢@Scipione提供有用的答案。如果你能指导我如何把一张图片作为一个单一的情节,我将不胜感激。我的意思是既不是点也不是标签,而是只有一个完整的绘图大小的图像。谢谢
library("ggplot2")
library("ggimage")
set.seed(2017-02-21)
d <- data.frame(x = rnorm(10),
                y = rnorm(10),
                image = sample(c("C:/YourDirectory/juventus.png",
                                 "C:/YourDirectory/sampdoria.png"),
                               size=10, replace = TRUE)
)

ggplot(d, aes(x, y)) + geom_image(aes(image=image), size=.05)