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

library("ggplot2")
library("ggimage")
set.seed(2017-02-21)
d <- data.frame(x = rnorm(10),
y = rnorm(10),
image = sample(c("https://www.r-project.org/logo/Rlogo.png",
"https://jeroenooms.github.io/images/frink.png"),
size=10, replace = TRUE)
)
ggplot(d, aes(x, y)) + geom_image(aes(image=image), size=.05)发布于 2018-05-26 19:08:06
非常简单,您只需设置保存要使用的.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)你得到的结果如下:

https://stackoverflow.com/questions/50546109
复制相似问题