2
我需要繪製圖像。我的問題是,我的PNG圖像不會調整到網格:如果您希望rasterGrob無需擴展將圖像大小調整爲ggplot2網格
library(webshot)
library(png)
webshot("http://www.doctormetrics.com/","doctor.png")
img <- readPNG("doctor.png")
dim(img)
x11()
g <- rasterGrob(img, interpolate=TRUE)
qplot(1:2, 1:2, geom="blank") +
annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) +
geom_point()
寬高比限制,你需要指定寬度和高度爲'unit(1,「npc」)' – baptiste
謝謝@baptiste,我把它寫下來! –