Bootstrap

R语言 | vscode R plot 不弹出图形窗口,看不到图怎么办?

原因未知。

现在可以逐行执行了,但是要在浏览器查看图片:

# install.packages("httpgd")
library(httpgd)
hgd()
httpgd::hgd_url() # 把输出的 url 复制到浏览器,查看接下来的绘图
# 同样打开设置面板,搜索 r.plot.usehttpgd,勾选 开启即可。

x = seq(0, 3 * pi, by = 0.1)
plot(x, sin(x), type = "l")
  • 支持拖拽改变长宽
  • 浏览器快捷键:d 删除当前图片,箭头键切换图片

Ref

  • https://github.com/REditorSupport/vscode-R/wiki/Plot-viewer
  • https://forum.posit.co/t/opening-httpgd-plot-in-external-window-through-vscode-workbench-proxy-server/188572
  • https://github.com/REditorSupport/vscode-R/wiki/R-Session-watcher
;