Re: [R] Displaying Grahics to the X Window when calling R from command line

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 16 Apr 2008 14:52:12 +0100 (BST)

I've just tried the following in 2.6.2

auk% cat x11.R
X11()
interactive()
plot(1:10)
locator()
q()

explicitly launch a device. It seems to be responsive enough (at least on my system) and will stay up until you middle- or right-click on the device surface. In earlier threads others have reported some problems with this approach, but see how it works for you.

On Wed, 16 Apr 2008, Pologruto, Thomas wrote:

> Thank you very much. Most appreciated.
>
>
>
>
> Please follow the attached hyperlink to an important disclosure:
> http://www.credit-suisse.com/legal/marketcommentary
>
>
> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley_at_stats.ox.ac.uk]
> Sent: Wednesday, April 16, 2008 8:52 AM
> To: Pologruto, Thomas
> Cc: r-help_at_r-project.org
> Subject: RE: [R] Displaying Grahics to the X Window when calling R from
> command line
>
> On Wed, 16 Apr 2008, Pologruto, Thomas wrote:
>
>> Thank you for your response. I tried searching the archives but did
>> not know that it was called X11() device.
>>
>> Can this be done in version 2.6.2 or do I need to have version 2.7.0
>
> Flag --interactive is only in 2.7.0. There is no simple way to get
> 2.6.2 to accept input redirected from a script and run the event loop on
> which
> X11() depends. (One non-simple way is to write an alternative front
> end.)
>
>> running? Also, when you say wait in my script, I need to put a sleep
>> or something in the script or else it will delete the plot when the
>> script exits?
>
> You need to ensure that the script does not exit, which will close the
> device (not just delete the plot). Sys.sleep() may not be sufficiently
> flexible -- one idea is to use locator() to get the viewer to click on
> the plot when done with it.
>
> Another route is to generate the plot as, say, a PNG file and launch a
> separate viewer to show that via system(wait=FALSE).
>
>
>> Thanks you again,
>> Tom
>>
>>
>>
>>
>> Please follow the attached hyperlink to an important disclosure:
>> http://www.credit-suisse.com/legal/marketcommentary
>>
>>
>> -----Original Message-----
>> From: Prof Brian Ripley [mailto:ripley_at_stats.ox.ac.uk]
>> Sent: Wednesday, April 16, 2008 3:12 AM
>> To: Pologruto, Thomas
>> Cc: r-help_at_r-project.org
>> Subject: Re: [R] Displaying Grahics to the X Window when calling R
>> from command line
>>
>> The issue is that the X11() device is the default device only in
>> interactive use, and further than the event loop is only run in
>> interactive use.
>>
>> You need to
>>
>> 1) make use of R 2.7.0 RC
>> 2) call R with R --vanilla --interactive
>> 3) arrange for your script to wait for something so the plot remains
> up.
>>
>> This has come up before, so please search the archives for more
> details.
>>
>>
>> On Tue, 15 Apr 2008, Pologruto, Thomas wrote:
>>
>>> Hi,
>>>
>>> I am running an R script from the command line by calling:
>>>
>>>> R --vanilla < test.R
>>>
>>> My terminal is part of the Xwin (Xterm) and there is a plot(1:10)
>>> command in the test.R script.
>>>
>>> This will not produce a grahic though.
>>
>> I think it does, on a PostScript or PDF file.
>>
>>> When I start R by calling R then
>>> plotting from the R command in the same xterm, I do get a graphic
>>> display.
>>>
>>> How do I create a xwin plot by calling R from the command line?
>>>
>>> Any help is most appreciated. I have preprocessed the data in perl
>>> and then feed it into my R script and want to see a plot on the
>> screen.
>>>
>>> Thanks,
>>> Tom
>>>
>>> =====================================================================
>>> = ======== Please access the attached hyperlink for an important
>>> electronic communications disclaimer:
>>>
>>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>>> =====================================================================
>>> =
>>> ========
>>>
>>> [[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.
>>>
>>
>> --
>> Brian D. Ripley, ripley_at_stats.ox.ac.uk
>> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford, Tel: +44 1865 272861 (self)
>> 1 South Parks Road, +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK Fax: +44 1865 272595
>>
>>
>> ======================================================================
>> ======== Please access the attached hyperlink for an important
>> electronic communications disclaimer:
>>
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>> ======================================================================
>> ========
>>
>>
>
> --
> Brian D. Ripley, ripley_at_stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>
>
> ==============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
>
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ==============================================================================
>
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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.
Received on Wed 16 Apr 2008 - 14:01:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Apr 2008 - 12:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive