无法显示png [英] Can't display png
问题描述
我在 VM(Red Hat Enterprise Linux Server 6.4 版)上运行 R-shiny(R 版本 3.0.1 (2013-05-16)).一切正常,即服务器启动,应用程序运行等......只要我不尝试绘制图形
I'm running R-shiny (R version 3.0.1 (2013-05-16)) on a VM (Red Hat Enterprise Linux Server release 6.4). Everything works, i.e., server starts up, and application runs etc... as long as I don't try to plot a graph
renderPlot
然后我在主面板上看到一条消息 [错误:无法启动设备 png].我会发布我的整个代码,但我认为这个问题与我使用时的渲染图有关渲染文本并吐出一些数据它工作得很好.
I then see on the main panel a message [error : unable to start device png]. I would post my whole code but this problem I think has to do with rendering plots as when I use renderText and spit out some data it works just fine.
实际上当我输入时png()在 R 我收到这个错误[.External2(C_X11, paste("png::", filename, sep = ""), g$width, 中的错误:无法启动设备 PNG另外: 警告信息:在 png() 中:无法打开与 X11 显示器的连接'']当然,如果我通过 ssh -X 转发到我的 mac,我可以输入 png() 没问题并绘制数据等...
Actually when I just type in png() in R I get this error [ Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, : unable to start device PNG In addition: Warning message: In png() : unable to open connection to X11 display '' ] of course if I forward via ssh -X to my mac, I can type in png() no problem and plot data etc...
-还有一些需要注意的地方,当我输入 capabilties() 时,我发现唯一错误的是 jpeg、tiff、X11、aqua 和 profmem(所以 png 和 cairo 是真实的)
-A few more things to note, when I type in capabilties() I find the only things that are false are jpeg, tiff, X11, aqua, and profmem (so png and cairo are True)
-在从源代码构建 R 之前,我已经安装了 libpng、cairo 和 libX11、libX11-devel、libXt、libXt-devel
-I've installed libpng, cairo, and libX11, libX11-devel, libXt, libXt-devel before building R from source
我猜我的问题是我需要运行 X 服务器.此外,DISPLAY 变量为空.
I'm guessing my problem is that I need to have X server running. In addition the DISPLAY variable is null.
所以,我想归结起来我的问题是......假设我的逻辑是正确的.
So, I guess when it boils down to it my question is ... assuming my logic is correct.
1) 我是否需要运行/启动 X 服务器 [目前它在启动后由于某种原因终止] 或者我可以只设置 DISPLAY 变量吗?
1) Do I need to run / start X server [ currently it terminates after starting for some reason] or can I just set the DISPLAY variable?
2) 如果我可以设置我的 DISPLAY 变量,我应该将它设置为什么(localhost:0.0 没有工作)
2) If I can just set my DISPLAY variable what should I set it to (localhost:0.0 hasn't worked)
显然,如果我遗漏了什么,这些问题可能无关紧要.
Obviously if there is something I'm missing these questions may be irrelevant.
提前致谢,抱歉啰嗦,想说得透彻一点.
Thanks in advance and sorry for rambling, wanted to be thorough.
PJ
推荐答案
如果设置 option(bitmapType = 'cairo')
有帮助吗?我一直怀疑 R 如何在 grDevices::.onLoad()
中使用 .Call(C_cairoProps, 2L)
选择位图设备类型(这可能是一个错误,但我不能肯定地说).
Does it help if you set option(bitmapType = 'cairo')
? I have been skeptical about how R chooses the bitmap device type using .Call(C_cairoProps, 2L)
in grDevices:::.onLoad()
(this might be a bug, but I cannot say it for sure).
如果cairo
的测试失败,选项bitmapType
回退到Xlib
,从而给你一个关于X11 的神秘错误信息代码>.注意
png()
中的 type
参数:
The option bitmapType
falls back to Xlib
if the test of cairo
fails, thus giving you a cryptic error message about X11
. Note the type
argument in png()
:
> args(png)
function (filename = "Rplot%03d.png", width = 480, height = 480,
units = "px", pointsize = 12, bg = "white", res = NA, ...,
type = c("cairo", "cairo-png", "Xlib", "quartz"), antialias)
这个参数的默认值是 getOption('bitmapType')
,在你的例子中它是 Xlib
由于 grDevices:: 中的测试:.onLoad()
.如果您 100% 确定 cairo
有效,您可以更改此选项,例如,在您的 ~/.Rprofile
中.
The default value of this argument is getOption('bitmapType')
, and in your case it is Xlib
due to the test in grDevices:::.onLoad()
. If you are 100% sure that cairo
works, you can change this option, say, in your ~/.Rprofile
.
这篇关于无法显示png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!