0

I have made a plot with these lines

mainland 
print(Bornhold, vp = viewport(x = 0.7, y = 0.5, width = 0.3, height = 0.2))

enter image description here One is mainland and the other an island. How can I save it to one one png file. I have found this link with the documentation but it only takes one object but the plot has two objects?

4
  • How did you include the image in the question?
    – Spacedman
    Commented May 2, 2019 at 13:07
  • @Spacedman: A screenshot.
    – xhr489
    Commented May 2, 2019 at 15:16
  • And what's wrong with that as a solution to your problem?
    – Spacedman
    Commented May 2, 2019 at 16:22
  • Could you edit the question and add more of the code, including libraries, that you used to produce the screenshot?
    – Simbamangu
    Commented May 3, 2019 at 12:04

2 Answers 2

1

If you have a plot that you'd like to save and didn't put (or don't like to put) the nested png() or pdf() followed by dev.off(), then you can use dev.copy2pdf() to save whatever is in the plot window as a PDF:

dev.copy2pdf(file = "myfile.pdf", width = 5, height = 3)

Unfortunately there isn't an option for PNG output that I'm aware of.

0

I have used this code to save the file as png

png("logo.png")
mainland 
print(Bornhold, vp = viewport(x = 0.91, y = 0.5, width = 0.3, height = 0.2))
dev.off()
list.files(pattern = "png")

I works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.