1

On a virtual machine on Azure, the following code produces a file with 4 KB that cannot be opened by a viewer:

pdf(pdf_filepath)
ggplot2::ggplot(...)
dev.off()

The code with png("...png") fails to even produce an image.

How to save a plot on a virtual machine without graphic devices?

miguelmorin
  • 4,227
  • 3
  • 23
  • 46

1 Answers1

0

Since you use ggplot2, you can use ggsave:

gplot2 <- ggplot2::ggplot(...)
ggsave(filepath, plot = gplot2, width = 14, height = 5, units = 'cm')

Also mentioned in this thread.

miguelmorin
  • 4,227
  • 3
  • 23
  • 46