[kepler-dev] RExpression image output

Dan Higgins higgins at nceas.ucsb.edu
Wed Dec 5 11:28:39 PST 2007


Hi Tristan,
    You point out a problem with graphics output from R that has 
bothered me for awhile. R happens to use some libraries that may or may 
not be present for some of its graphics devices. For example, the 'png' 
device uses some X11 libraries on Linux and the Mac (but not on 
Windows). I assume that you are on a Linux/Unix server which does not 
have X11 installed.
    The solution that I came up with for the Mac was to use the 'pdf' 
option for graphics. This seemed to work across all the OSs and the 
image is actually scalable without losing resolution. Does that option 
not work for you?
    I hadn't tried the 'bitmap' device that you suggest. R documentation 
indicates that 'bitmap' uses postscript via 'GhostScript'. I avoided 
this because not all systems have GhostScript installed (particularly 
Mac and Windows, although I did not check R for these platforms)

    Another option is to override the RExpression code that sets the 
graphicsDevice by setting the device to whatever you want in your 
RExpression script. ie simply add a statement like
bitmap(file='FileName.bmp', width=640, height=640)
to the beginning of the script. This changes the graphicsDevice to a 
'bitmap' and puts it into a file name 'FileName.bmp' (rather than the 
default graphics port file name). You can thus customize output using 
the script rather than changing RExpression Java code.

Dan Higgins
NCEAS - UCSB

PS - R on Windows does not seem to work with the 'bitmap' graphicsDevice.

Tristan King wrote:
> Hi all,
> In trying to get the RExpression actor working from my web ui, I came
> across the problem with the use of the R function png to create images.
> this function requires an X11 session (i'm not sure what it does under
> windows), and if one is unavailable the RExpression actor fails.
>
> i changed line 330 of RExpression.java to read:
> graphicsDevice = "bitmap(file = '" + graphicsOutputFile + "', type =
> \"png256\", width = " + nxd + ", height = " + nyd + ")";
> which allows me to run the test/R_3D_Plot.xml example, but i know very
> little about R or how this actor works to know if there are going to be
> any problems with other workflows in other situations.
>
> Maybe a better solution would be to add an extra property to the actor
> to specify whether X11 is available and use png if it is, and bitmap if
> it's not (doing this automatically would be better, but i don't know if
> it's possible to detect X11 in code).
>
> -Tristan
>
> _______________________________________________
> Kepler-dev mailing list
> Kepler-dev at ecoinformatics.org
> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>
>   


-- 
*******************************************************************
Dan Higgins                                  higgins at nceas.ucsb.edu
http://www.nceas.ucsb.edu/    Ph: 805-893-5127
National Center for Ecological Analysis and Synthesis (NCEAS) Marine Science Building - Room 3405
Santa Barbara, CA 93195
*******************************************************************



More information about the Kepler-dev mailing list