Home > other >  Save images in R
Save images in R

Time:10-26

Does anyone use the function save_plot from the package cowplot to save the picture instead of ggsave. How we can set up the output? I did use the default setting and the output pic was set into AppData\\Local\\Temp\\RtmpuSVbq4\\tree_test2730600e55ae.pdf"

But when I go to that folder, the picture did not appear.

Thanks in advance!!!

CodePudding user response:

Try the following:

pdf("/tmp/example.pdf")
plot(1:10,sin(1:10)) # Draw here your plot
dev.off()

CodePudding user response:

Try,

p1 <- ggplot(mpg, aes(x = cty, y = hwy, color = factor(cyl)))  
  geom_point(size = 2)  
  theme_half_open()
file1 <- tempfile("file1", fileext = ".png", tmpdir = getwd())
save_plot(file1, p1)
  • Related