Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rgl.postscript: file saved without varying text sizes

Tags:

r

pdf

rgl

From @DWin and @Ben Bolker, we can change the scatter3d function in R to plot "prettier" (http://stackoverflow.com/questions/8204972/carscatter3d-in-r-labeling-axis-better), however, saving the plot is a trickier. rgl.snapshot saves the image as a png but to save a high resolution image (PDF) rgl.postscript must be used. Using rgl.postscript will not save the image with font/text size/axis sizes as specified (I edited the scatter3d function to increase text/axis sizes). rgl.snapshot works as it should so why doesn't rgl.postscript? Does anyone know an alternative saving method or is there a way to save the plot with larger text/axis etc?

like image 476
Megan Avatar asked Mar 23 '26 01:03

Megan


1 Answers

A simple example works for me with the a more recent version of rgl than the CRAN one (CRAN has 0.92.798, r-forge now has 0.92.836, this is with 0.92.829). It looks like versions are numbered by SVN revision, so this is one version after the update mentioned in the comments above ...

library(rgl)
set.seed(1001)
n <- 20
text3d(runif(n),runif(n),runif(n),LETTERS[1:n],cex=seq(0.5,5,length=n))
rgl.postscript(file="tmp.ps")

However, a big warning is that the resulting PS, PDF, files etc. are a bit wonky. The bounding boxes are a little odd, although I could text-edit that manually. ps2pdf and ps2png mangled it .. epstopdf seems to have worked (these are all tools that are available on Linux boxes, don't know about for other OS). In principle rgl.postscript() allows you to export as PDF, but it might be weird PDF ... StackOverflow doesn't recognize the file as being in a valid upload format.

R Under development (unstable) (2012-01-01 r58032)
Platform: i686-pc-linux-gnu (32-bit)

[snip]

other attached packages:
[1] rgl_0.92.829

enter image description here

like image 187
Ben Bolker Avatar answered Mar 24 '26 15:03

Ben Bolker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!