Skip to content

ggsave() can change active graphics device #2363

Closed
@wch

Description

@wch

If there is more than one graphics device open, calling ggsave() can change which one is active.

For example, in RStudio:

library(ggplot2)

dev.new()
dev.new()
dev.cur()
#> quartz 
#>      4 

p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
ggsave('test.png', p)
dev.cur()
#> RStudioGD 
#>         2 

In R at the terminal:

library(ggplot2)

dev.new()
dev.new()
dev.cur()
#> quartz 
#>      3 

p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
ggsave('test.png', p)
dev.cur()
#> quartz 
#>      2 

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