本文介绍了如何删除 RStudio 绘图设备中的当前(但不是全部)绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除 RStudio 绘图设备中的当前(但不是全部)绘图?

How do you delete the current (but not all) plots in the RStudio plotting device?

dev.off() 将删除所有图,但如果我只想删除一个怎么办?我不想按那个红色的x"按钮,因为我想不按任何按钮就删除一个图.

dev.off() will remove all plots, but what if I just want to remove one? I don't want to have to press that red 'x' button because I want to remove one plot without pressing a button.

推荐答案

在 R 中,您只需在每个绘图之前使用 dev.new(),因此您 dev.off() 只清除最后一个情节.

In R, you would just use dev.new() before each plot, so you dev.off() to only clear the last plot.

在 RStudio 中,您可以在每个绘图之前使用 x11()windows()quartz()(取决于您的设备).然后调用 dev.off() 清除最后一个绘图.您还可以使用 dev.set() 以这种方式选择特定的图.

In RStudio, you can use x11(), windows() or quartz() (depending on your device) before each plot. Then call dev.off() to clear last plot. You can also use dev.set() to choose specific plots that way.

如果您的问题是专门要求删除同一 RStudio 窗口中的最后一个绘图(而不是创建新窗口),请不确定是否可行,因为 RStudio 将该窗口视为一个设备.一个想法是寻找一种在 RStudio 项目中调用 C++ 函数 removePlot() 的方法.

If your question is specifically asking to delete the last plot within the same RStudio window (rather than making new windows), not sure if it's possible, since RStudio treats that window as one device. An idea would be to look at a way to call the C++ function removePlot() in the RStudio project.

我在 G 存储库中找到对于 RStudio C++ 代码:

I found in the Github repository for RStudio the C++ code:

display.removePlot(display.activePlotIndex());

您可以通过这种方式输出绘图并管理文件.

You could output the plots and manage the files that way.

这篇关于如何删除 RStudio 绘图设备中的当前(但不是全部)绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 21:27