[R] Trying to save both an rgl plot and a bar plot errors

Duncan Murdoch murdoch at stats.uwo.ca
Sun Oct 25 20:10:41 CET 2009


On 25/10/2009 9:10 AM, jamesgiacmo at aol.com wrote:
> Hello,

> I am basically using a script that is designed to first create an rgl
> 3d scatter plot followed by a barplot on the same data. After this is
> done, the program is to first save the barplot as a .tiff file then
> to save the rgl 3d graph as a .png file. Once this is done, it is to
> repeat this 3d plot and barplot combo with saving 49 more times. The
> plotting script excerpt will be posted at the end of this email, and
> yes, the "setwd(...)" command is used correctly in the script just
> censored here. I have basically had problems with this script in
> three different ways.

> In Windows Vista Home Premium, all 50 graph pairs are generated and
> the barplots are saved just fine as .tiff files, but the rgl .png
> files are saved as a giant black square instead of a graph. 

rgl relies on the graphics device driver for some of this work.  If you 
find it works outside a loop but not inside one, maybe you just need to 
introduce a delay using sleep() to let the hardware/device driver catch up.

The other
> problem with Vista is that when I save the workspace image, it does
> not reload when I intentionally load the image. There are no error
> messages, all console evidence shows that the image loaded just fine
> but nothing shows up.

I don't know what you mean here, but it sounds as though you think 
loading the image will show a figure.  In this context, "image" is not 
something visual, it's just a copy of the R objects in your workspace.


  I have also tried this on Mac OSX Snow Leopard
> (10.6). The machine stops after the first barplot is generated and
> states that there is an error in the 'savePlot' command and that
> X11(type ="*cairo") is not understood or something to the effect [I
> do not have the Mac with me at the time]. The script just stops after
> this error, so I do not know if the rgl or the .Rimage files save
> properly yet. Thank you for your time, James Thomas

Can't help you with that one.

> 
> # PLOT open3d() dev.new() setwd(...) plot3d(SN_PCA_All,
> col=rainbow(nrow(SN_PCA_All))) decorate3d(main ="SN_All_Ca") 
> barplot(SN_Scree_All_Percent[,1], main = "SN_All_Ca") 
> savePlot(filename = "01 +S+Na_AllCa_Scree", type ="tiff") 
> rgl.viewpoint(180,0) rgl.snapshot("01 +S+Na_AllCa_PCA.png",
> fmt="png", top=TRUE ) #

I'd avoid putting spaces in filenames; in most situations it's fine, but 
occasionally you'll run across software that doesn't work properly with 
them.  I don't think that's involved in the problems you saw above.

Duncan Murdoch

> 
> [[alternative HTML version deleted]]
> 
> ______________________________________________ R-help at r-project.org
> mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
> read the posting guide http://www.R-project.org/posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list