为什么“ angle”参数使ggplot2中geom_image中的点偏离所需位置?
演示数据:
d <- data.frame(x = 1:N,
y = 1:N,
image = rep("https://www.r-project.org/logo/Rlogo.png", N),
angle = seq(0, 45, length.out=N)
)
演示:
library("ggplot2")
library("ggimage")
p <- ggplot(d, aes(x, y))
for (i in 1:dim(d)[1]){
di <- d[i, ]
p = p +
geom_image(data = di, aes(image=image), angle = di$angle[1]) +
geom_point(data=di)
}
p
答案 0 :(得分:2)
library("ggplot2")
library("grid")
grid.newpage()
grid.points(x = 0.5, y = 0.8, default.units = "npc", pch="+",gp=gpar(cex=5))
grid.raster(png::readPNG(system.file("img", "Rlogo.png", package="png")),
x = 0.5, y = 0.8, vp = viewport(angle=45), height=unit(1,"cm"))
grid.raster(png::readPNG(system.file("img", "Rlogo.png", package="png")),
vp = viewport(x = 0.5, y = 0.8, angle=45), height=unit(1,"cm"))