【发布时间】:2021-05-21 22:12:45
【问题描述】:
我在 Ubuntu 18.04 上使用 RStudio 1.4。我使用外部设备 X11 来查看图形,因为我经常需要一次显示多个绘图。我想让 ggplot 默认在新设备中显示每个绘图,就好像 ggplot 调用总是在调用 dev.new() 之前一样。我不必做一堆手动关闭窗口。有没有办法拥有这种默认行为?下面是一个 MWE。
library(tidyverse)
options(device = "X11")
# regular default behavior, where a new ggplot call will overwrite the plot in the active device (if any)
mtcars %>%
ggplot(aes(x = cyl, y = mpg)) +
geom_point()
# desired default behavior, where a new device is created with the ggplot call
dev.new(); mtcars %>%
ggplot(aes(x = cyl, y = mpg)) +
geom_point()
【问题讨论】:
标签: r ggplot2 graphics window x11