我制作了一个 300 万点的绘图并将其保存为 PNG。花了几个小时,我想避免重新绘制所有点。
如何生成以此 PNG 作为背景的新绘图?
最佳答案
试试这个:
library(png)
#Replace the directory and file information with your info
ima <- readPNG("C:\\Documents and Settings\\Bill\\Data\\R\\Data\\Images\\sun.png")
#Set up the plot area
plot(1:2, type='n', main="Plotting Over an Image", xlab="x", ylab="y")
#Get the plot information so the image will fill the plot box, and draw it
lim <- par()
rasterImage(ima, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4])
grid()
lines(c(1, 1.2, 1.4, 1.6, 1.8, 2.0), c(1, 1.3, 1.7, 1.6, 1.7, 1.0), type="b", lwd=5, col="white")
下面是剧情
关于r - 如何以 png 作为背景进行绘图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12918367/