wilkelab / cowplot

cowplot: Streamlined Plot Theme and Plot Annotations for ggplot2
https://wilkelab.org/cowplot/
701 stars 84 forks source link

Calling save_plot( ) non-interactively via Rscript creates empty Rplots.pdf file #204

Open cdupai-bbi opened 4 months ago

cdupai-bbi commented 4 months ago

Similar to this ggsave bug (https://github.com/tidyverse/ggplot2/issues/2787), running save_plot() non-interactively with Rscript in the terminal produces the empty, unwanted file Rplots.pdf.

library(tidyverse)
library(cowplot)

plot_this <- 
  ggplot( data = data.frame( x=c(1,2,4), y = c(2,3,5)))+
  geom_point(aes(x = x ,y = y))

save_plot(
  "test.png",
    plot_this ,
    base_height = 6,
    bg = "white")