不能在远程R会话中使用X11,但是可以在Python会话中使用吗?

发布于 2025-01-27 09:21:29 字数 2404 浏览 4 评论 0原文

我想在远程服务器上使用R绘图。我在Mac上,我已经安装了Xquartz,并且我正在与ssh -x -y name@server连接(结果我仅使用x或y还是两者都一样)。一旦我在远程服务器上,我可以打开Xeyes,并在Python中绘制以下内容:

import matplotlib.pyplot as plt
plt.plot([1,2],[4,2])
plt.show()

但是我无法弄清楚如何在R中绘制R。 >我在x11()中获得错误:X11不可用。由于我可以使用Python和Xeyes获得一个X11窗口,因此我想我缺少某种R包,但是对于它的本质来说,我不知所措。任何帮助都将受到赞赏!

$ R

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> x11()
Error in x11() : X11 is not available
>
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /PATH/TO/Ubuntu18.04/rstats-4.0.3/lib/R/lib/libRblas.so
LAPACK: /PATH/TO/Ubuntu18.04/rstats-4.0.3/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US       LC_NUMERIC=C         LC_TIME=en_US       
 [4] LC_COLLATE=en_US     LC_MONETARY=en_US    LC_MESSAGES=en_US   
 [7] LC_PAPER=en_US       LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=en_US LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.3
>
>
> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua 
       TRUE        TRUE        TRUE        TRUE       FALSE       FALSE 
   http/ftp     sockets      libxml        fifo      cledit       iconv 
       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
        NLS     profmem       cairo         ICU long.double     libcurl 
       TRUE       FALSE        TRUE        TRUE        TRUE        TRUE 
$ echo $DISPLAY
SERVER:14.0

I want to use R plotting on a remote server. I'm on a mac, I have XQuartz installed, and I am connecting with ssh -X -Y NAME@SERVER (results are the same whether I use just X or Y or both). Once I'm on the remote server I can open xeyes and plot in python with:

import matplotlib.pyplot as plt
plt.plot([1,2],[4,2])
plt.show()

But I can't figure out how to plot in R. When I type x11() I get Error in x11(): X11 is not available. Since I can get an X11 window with python and xeyes, I imagine I'm missing some sort of R package, but I'm at a loss as to what it is. Any help is appreciated!

$ R

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> x11()
Error in x11() : X11 is not available
>
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /PATH/TO/Ubuntu18.04/rstats-4.0.3/lib/R/lib/libRblas.so
LAPACK: /PATH/TO/Ubuntu18.04/rstats-4.0.3/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US       LC_NUMERIC=C         LC_TIME=en_US       
 [4] LC_COLLATE=en_US     LC_MONETARY=en_US    LC_MESSAGES=en_US   
 [7] LC_PAPER=en_US       LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=en_US LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.3
>
>
> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua 
       TRUE        TRUE        TRUE        TRUE       FALSE       FALSE 
   http/ftp     sockets      libxml        fifo      cledit       iconv 
       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
        NLS     profmem       cairo         ICU long.double     libcurl 
       TRUE       FALSE        TRUE        TRUE        TRUE        TRUE 
$ echo $DISPLAY
SERVER:14.0

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文