[R] get current window (device) size

David Winsemius dwinsemius at comcast.net
Mon Feb 15 16:05:38 CET 2010


On Feb 15, 2010, at 9:49 AM, <Edmond.Ng at lshtm.ac.uk> wrote:

> Dear Prof Ripley,
> Thank you very much for your advice. In fact, I have already tried
> 'par("din")'. It does not seems to pick up the changes made to the
> window. For example, I issued the par command after the plot:
>
>> par("din")
> [1] 7.5 7.0
> [changed window size]
>
>> par("din")
> [1] 7.5 7.0
> The result is exactly the same after changes made to the window.  
> Thanks
> again.

Try plotting after changing the size and re-querying "din":
 > par("din")
[1] 7 7
<change window size>
 > par("din")
[1] 7 7
 > plot(1,1)
 > par("din")
[1] 3.940054 7.268841
<change window size again, but no replotting>
 > par("din")
[1] 7.144498 4.899888

-- 
David.


>
> Best wishes,
> Edmond
>
>>>> Prof Brian Ripley <ripley at stats.ox.ac.uk> 15/02/10 14:35 >>>
> On Mon, 15 Feb 2010, Edmond.Ng at lshtm.ac.uk wrote:
>
>> Dear R-listers,
>>
>> I am writing a function that will generate a simple plot for the
>> user . The size of the window (that contains the plot) may not be
>> what the user wants.
>>
>> Supposing the user adjusts the window to a size of her/his choice, I
>
>> would like to be able to save the new window size and specify the
>> plot to be of this new window size when the user calls my function
>> again. My question is what is the kind of 'get' or save graphic
>> parameter command that I need to extract the size of the current
>> window? I have looked at 'par' and 'getOption' but they don't seem
>> to what I need.
>
>> From the help for par:
>
>      ̔din̓ _*R.O.*_; the device dimensions, ̔(width,height)̓, in
>           inches.
>
> seems to be exactly what you are asking for.
>
> (I'd be cautious about saving this across sessions: users may well use
>
> R on different computers with a common file system.)
>
>> Many thanks for any advice in advance.
>>
>> Best wishes,
>> Edmond
>>
>>
>>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
> ++
>> Edmond Ng, MSc CStat
>> Lecturer in Medical Statistics
>> Health Services Research Unit, London School Hygiene & Tropical
> Medicine, Keppel Street, London WC1E 7HT, UK
>> Tel: +44 (0)20 7927 2366 (direct line: ext 2065)  Fax: +44 (0)20 7580
> 8183
>> (Room 35, Ground Floor, Malet Street side)
>> Website: http://www.lshtm.ac.uk/hrsu
>>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
> ++
>
> -- 
> 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
>
> 	[[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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list