[R] How to pop up the graphics window from Rscript?

David Winsemius dwinsemius at comcast.net
Sun Sep 6 20:41:02 CEST 2009


On Sep 6, 2009, at 1:42 PM, Gabor Grothendieck wrote:

> Try this (contents of plot.R):
>
> png("mygraphic.png")
> plot(1:10)
> dev.off()
> browseURL("mygraphic.png")
>
> It will pop up the graphic in a browser window.

On a Mac that shows up in a Preview window. The X11() device does open  
a plot on a Mac when this file is submitted:

x=1:10
y=1:10
X11()
plot(x,y)
dev.off()

I was under the impression that no surrounding box was displayed since  
the points were visible for several seconds before the window  
disappeared. But testing from a GUI session, I see that the X11 device  
takes a long time to draw the axes, which has a side-effect in the  
Rscript session of displaying the points for several seconds and the  
axes for only milliseconds.

-- 
David.

Mac OS 10.5.7/R 2.9.1 Patched (2009-07-04 r48897)

>
>
> On Sun, Sep 6, 2009 at 12:53 PM, Peng Yu<pengyu.ut at gmail.com> wrote:
>> Hi,
>>
>> I am wondering how to pop up the graphics window from Rscript. I run
>> the following code, but I don't see the graphics window, even
>> transiently.
>>
>> Regards,
>> Peng
>>
>> $ Rscript plot.R
>>> x=1:10
>>> y=1:10
>>> plot(x,y)
>>>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list