Abdel
Abdel

Reputation: 6106

R: plot with pdf as background

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!

Upvotes: 6

Views: 1710

Answers (1)

Abdel
Abdel

Reputation: 6106

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...)

Upvotes: 3

Related Questions