Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: plot with pdf as background

Tags:

plot

r

pdf

I would like to plot in R using an existing pdf file as the background. The reason I don't want to use another format (png, jpg, gif), is that I don't want to lose any quality of the image in my (already existing) pdf file. Any recommendations? Many thanks!

like image 874
Abdel Avatar asked Feb 13 '12 10:02

Abdel


1 Answers

Thanks a lot tim riffe! I found the answer in that document:

First convert the pdf to ps. Then do the rest with the grImport package:

#convert the ps to xml:
PostScriptTrace("image.ps")

# store the xml info in RGML format (R Graphics Markup Language):
NLmap <- readPicture("image.ps.xml")

#plot the image
plot(etc...)
par(new=T)
plot(grid.picture(NLmap[-1]),etc...)
like image 156
Abdel Avatar answered Oct 20 '22 03:10

Abdel