0

I've been trying (unsuccessfully) to export a postscript or pdf snapshot of a persp3d plot using rgl.postscript. I've added code from ?rgl.postscript which works for me without error in R but produces a 0 KB postscript file. Any ideas?

x <- y <- seq(-10,10,length=20)
z <- outer(x,y,function(x,y) x^2 + y^2)
persp3d(x,y,z, col='lightblue')

title3d("Using LaTeX text", col='red', line=3)
rgl.postscript("persp3da.ps","ps",drawText=FALSE)

FYI, I'm running R version 3.1.1 (2014-07-10), Windows 8 (64-bit), rgl package 0.94.1143

Paul Regular
  • 498
  • 4
  • 8
  • Can't reproduce. This code works for me, but I am in OSX. In OSX I need to have X11 installed. Maybe the Windows version has similar requirements? – ddiez Oct 10 '14 at 13:36
  • After second thought- I assumed title3d() produces the desired output. Does it? – ddiez Oct 10 '14 at 13:37
  • Yup, everything - including title3d - prints as expected in R...but for some reason rgl.postscript doesn't put anything into the postscript or pdf – Paul Regular Oct 10 '14 at 13:44
  • Just a silly comment in case... rgl.postscript() created a A4 ps file with the image at the bottom. When I opened at first thought it was empty until I realized and scrolled down the page. There is no way that is what's happening? – ddiez Oct 10 '14 at 13:55
  • A more serious comment, I imagine rgl.postscript() uses ghostscript or something alike to create the postscript file. Could it be that you need to install it? – ddiez Oct 10 '14 at 13:56
  • Good thinking! I have ghostscript installed but I didn't make sure R could find it. Alas, after specifying the path to ghostscript using Sys.setenv(), I still get nothing :( – Paul Regular Oct 10 '14 at 14:06
  • 1
    Have you tried using a different format, with rgl.postscript(, fmt="pdf") or something else? See ?rgl.postscript for format options. Otherwise I am currently out of ideas! Unfortunately do not have a windows machine to test. – ddiez Oct 11 '14 at 07:28
  • Yup, gave all the options a try (I should have clarified that in the question). Many thanks for sharing your ideas! – Paul Regular Oct 11 '14 at 11:33

0 Answers0