Skip to content

Non-interactive calls to ggsave() can have irritating side effects #1326

@jennybc

Description

@jennybc

Posting an issue sort of on behalf of @cscheid because I am so thrilled at the prospect of this getting fixed! (Please correct me if I'm mangling your problem, @cscheid.)

Calls to ggsave() that don't specify device width and height cause a graphics device to be opened and consulted for dimensions. In non-interactive settings, this can have irritating side effects, such as leaving an (empty or corrupt) Rplots.pdf file behind.

Reprex: put these commands in foo.R:

library(ggplot2)
p <- ggplot(mtcars, aes(x=cyl,y=mpg)) + geom_point()
ggsave("cars.png", p)

and run Rscript foo.R. This produces cars.png AND Rplots.pdf, at least on my Mac.

Other places people where people have vented about this: stackoverflow thread How to stop R from creating empty Rplots.pdf file when using ggsave and Rscript, ggplot2 board thread ggsave always opens a graphics window on Mac OS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions