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?

  • How did you include the image in the question? – Spacedman May 2 at 13:07
  • @Spacedman: A screenshot. – David May 2 at 15:16
  • And what's wrong with that as a solution to your problem? – Spacedman May 2 at 16:22
  • Could you edit the question and add more of the code, including libraries, that you used to produce the screenshot? – Simbamangu May 3 at 12:04
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, privacy policy and cookie policy

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