[kepler-dev] RExpression image output

Dan Higgins higgins at nceas.ucsb.edu
Thu Dec 6 06:51:54 PST 2007


Hi Tristan,
    You are perfectly correct about the preset graphics device crashing 
R. What I forgot is that the 'png' code added at the start can be 
'turned off' by setting the Graphics Output parameter to false!  (see 
line #322). You should then be able to customize the graphicsDevice 
within the script.

Dan Higgins

Tristan King wrote:
> On Wed, 2007-12-05 at 11:28 -0800, Dan Higgins wrote:
>   
>> 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.
>>     
>
> This was what I originally wanted to do, but from what i could tell,
> since the fire() code add's the png() call at the start of each script,
> it crashes R before it can get to any other calls.
>
> i.e.
>   
>> setwd('/home/tristan/projects/jcu/WebPortal/storage/jobs/18/')
>> png(filename = 'RExpression1.png',width = 480, height = 480, pointsize = 12, bg = 'white')
>>     
>
> Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,  : 
> 	unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display '' in: png(filename = "RExpression1.png", width = 480, height = 480,  
> Execution halted
>
> So no matter what i put in the RExpression, it will always die on me.
> I thought about extending the actor itself, but it would pretty much be
> a copy+paste of the entire fire() method for a single change (and would
> be a pain keeping it up to date with the original actor).
>
> maybe the answer is creating a few more values for graphicsFormatString,
> i.e. png-ps and png-x11, or something along those lines. That would work
> well for me, as i can always force png-ps if png-x11 is selected. 
>
> pdf isn't a great solution for me, as i'm trying to embed the output
> into a web page, and i don't think (tho i will check) that the img tag
> works with pdfs (tho i'm sure browser compatibility for display of pdfs
> will ruin it even if it does).
>
>
>   



More information about the Kepler-dev mailing list