1

I have been using ggsave for years with no problem. But now it suddenly stopped saving plots. It saves an empty png. Here's an example (very primitive to show that the problem is not in the plot itself):

col2=brewer.pal(n=11, name = "Spectral")
barplot((1:11), col=col2)
ggsave("plot1.png")

The plot appears in Rstudio but not in the saved figure. I recently updated Rstudio ("Ghost Orchid" Release (077589bc, 2021-09-20)) and R (4.1.1 (2021-08-10) -- "Kick Things"). What could be the problem?

Thanks!

MrFlick
  • 195,160
  • 17
  • 277
  • 295
SKay
  • 23
  • 4
  • 4
    `barplot` is not a ggplot function. That's a base R plotting function. Base R plotting functions do no interact with `ggsave`. So either use a ggplot function or [save the base R way](https://stackoverflow.com/questions/7144118/how-to-save-a-plot-as-image-on-the-disk) – MrFlick Oct 22 '21 at 19:15
  • well, ok, in reality I used pheatmap. The result was the same. – SKay Oct 22 '21 at 19:29
  • 5
    `pheatmap` is also not a gpplot function. If you are not calling `ggplot()`, then changes are good you're not using ggplot. You should be able to shave `pheatmap` images using the base R method. See: https://stackoverflow.com/questions/43051525/how-to-draw-pheatmap-plot-to-screen-and-also-save-to-file – MrFlick Oct 22 '21 at 19:32
  • Thanks a lot, this looks very useful! – SKay Oct 22 '21 at 19:43

0 Answers0