Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rgl.postscript when rgl.useNULL = TRUE

Tags:

r

rgl

Shouldn't rgl.postscript() work for a headless server, i.e. when options(rgl.useNULL = TRUE)? I know that rgl.snapshot() won't work.

library(rgl)
options(rgl.useNULL = TRUE)
open3d()
x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x, y)
plot3d(x, y, z, col = rainbow(1000))
rgl.postscript("test.pdf",fmt="pdf")

This gives me "In rgl.postscript("test.pdf", fmt = "pdf") : Postscript conversion failed".

like image 765
jorkku Avatar asked Oct 19 '22 11:10

jorkku


1 Answers

It could do so in some cases, but currently it doesn't. One issue is that if rgl is started with the null device, it won't even link in the OpenGL functions, and rgl.postscript() uses some of them.

Edit: Sorry, the "no linking" is what I'd like. Currently it does need to link, but it won't run the initialization code, so it should work in contexts (e.g. a headless server) where no display is available.

On a headless server you could use Xvfb for a "virtual frame buffer". I don't have a lot of experience with it, but I think I've heard that it doesn't handle rgl.snapshot properly. I'd expect rgl.postscript to work.

In principle, you could also render in WebGL, and then use some other tool to convert the output to your desired format. I don't know if any such tools exist.

like image 190
user2554330 Avatar answered Oct 27 '22 21:10

user2554330