在 (r)gedit 中显示多个 R 图形窗口

发布于 2024-09-17 10:23:02 字数 94 浏览 4 评论 0原文

我正在使用 gedit 的 rgedit 插件。 我想允许一次显示多个图形(绘图)窗口。目前,每当我 plot() 时,绘图都会覆盖之前的绘图窗口。

I'm using rgedit plugin for gedit.
I would like to allow more than one graphic (plot) window to show at a time. Currently, whenever I plot(), the plot overwrites the previous plot window.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

静待花开 2024-09-24 10:23:03

只是为了补充德克的答案,您还可以在同一窗口中绘制多个图形,请查看 ?par,特别是 mfrow 参数

例如 par( mfrow=c(2,2)) 将为您提供 2x2 的绘图布局。

对于更复杂的布局,请参阅 ?split.screen?layout


要在设备之间切换,您可以执行以下操作:

# Create 3 plots
dev.new()  # Or X11()
dev.1 <- as.integer(dev.cur())
dev.new()
dev.2 <- as.integer(dev.cur())
dev.new()
dev.3 <- as.integer(dev.cur())

x <- seq(1, 100, 0.1)

# Switch to device 1
dev.set(dev.1)
plot(x, sin(x), "l")
# Switch to device 3
dev.set(dev.3)
plot(x, cos(x), "l")
# Add something to graph #1
dev.set(dev.1)
points(x, cos(x), "l", col="red")

请注意,尽管您存储在 dev 中的设备编号.1dev.2dev.3 大多数情况下是连续的 (1,2,3),您应该始终使用 dev.cur< /code> 获取设备的编号,因为您不能安全地假设它们恰好是 1,2,3 等...(您可能打开了其他设备)

Just to add to Dirk's answer, you can also plot multiple graphs in the same window, look at ?par, in particular at the mfrow parameter

For instance par(mfrow=c(2,2)) will give you a 2x2 layout for your plot.

For more complex layouts see ?split.screen and ?layout


To switch between devices you can do:

# Create 3 plots
dev.new()  # Or X11()
dev.1 <- as.integer(dev.cur())
dev.new()
dev.2 <- as.integer(dev.cur())
dev.new()
dev.3 <- as.integer(dev.cur())

x <- seq(1, 100, 0.1)

# Switch to device 1
dev.set(dev.1)
plot(x, sin(x), "l")
# Switch to device 3
dev.set(dev.3)
plot(x, cos(x), "l")
# Add something to graph #1
dev.set(dev.1)
points(x, cos(x), "l", col="red")

Note that, although the devices numbers you're storing in dev.1, dev.2 and dev.3 will mostly be sequential (1,2,3) you should always use dev.cur to get the number of the device, as you cannot safely assume they will be exactly 1,2,3 etc... (you may have other devices open)

倾其所爱 2024-09-24 10:23:03

或者您可以打开一个新的控制台选项卡,但这并不像 Dirk 和 nico 提出的建议那么优雅(您必须提交代码两次)。

Or you could open a new console tab, but this isn't as elegant (you have to submit your code twice) as the suggestions made by Dirk and nico.

绾颜 2024-09-24 10:23:02

不是 gedit 问题,而是一般 R 功能 - 使用 x11() (或 windows())创建新的绘图设备。

然后您可以使用 dev.set() 等在它们之间切换。

Not a gedit issue but a general R feature -- use x11() (or windows()) to create new plot devices.

You can then use dev.set() et al to flip between them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文