[R] Plotting to stdout
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Aug 28 13:33:02 CEST 2009
On Fri, Aug 28, 2009 at 7:16 AM, Gábor Csárdi<csardi at rmki.kfki.hu> wrote:
> On Fri, Aug 28, 2009 at 1:06 PM, Oliver Bandel<oliver at first.in-berlin.de> wrote:
> [...]
>> The goal was to produce a picture in a web-environment.
>>
>> At the moment rpy2 will be used.... maybe there are way to achieve something
>> like that in this way, but I'm also new to rpy2.
>>
>> When the graphic could be written to stdout, the calling environment could reead
>> it from the forked process.
>>
>> But maybe rpy2 works different.
>>
>> Any ideas on that on-the-fly creation of pictures?
>> If there would be no temporary files this would be fine.
>> That's the reason why I looked for stdout as output channel.
>
> Oliver,
>
> I have a similar problem and had a similar question on the list about
> a week ago.... all I could find out that some devices of the Cairo
> package are supposed to support plotting to R connections (including
> stdout), but it does not work in practice:
>
>> library(Cairo)
>> tc <- textConnection("foo", "w")
>> CairoPNG(file=tc)
> Error in Cairo(width, height, type = "png", file = filename, pointsize
> = pointsize, :
> file must be a filename. to support writing to a connection,
> recompile R and Cairo with the R Connection Patch.
>
> Information on the "R connection Patch" is welcome. Recompiling R and
> Cairo is not a problem for me, I am putting together a special
> environment anyway.
>
> Best,
> Gabor
>
> [...]
>
I could have used this functionality in a previous project as well; however,
for Oliver's application just pass the filename to the python program use that
in the <img src=...> tag (or have the python program pass the filename to
the R program).
If there is some aspect of this problem that has not been explained that
truly does make passing the graphic file contents to the python
program desirable
then have R write out the graphic file and then have R read it back in.
More information about the R-help
mailing list