如何以png为背景进行绘制? [英] How to plot with a png as background?
本文介绍了如何以png为背景进行绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用300万点绘制了一个情节,并将其另存为PNG.花了几个小时,我想避免重提所有问题.
I made a plot with a 3 million points and saved it as PNG. It took a few hours and I would like to avoid re-drawing all the points.
如何生成以该PNG为背景的新绘图?
How can I generate a new plot that has this PNG as a background?
推荐答案
尝试一下:
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")
下面是情节.
这篇关于如何以png为背景进行绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文