[R] About plot graphs

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Aug 27 10:21:13 CEST 2010


On Thu, 2010-08-26 at 21:01 -0700, Stephen Liu wrote:
> Hi Greg,
<snip />
> > windows(width=12, height=6)
> Error: could not find function "windows"

So you aren't on Windows then... Hence why the posting guide asks for
sessionInfo() details; sometimes it matters.

Anyway, a OS independent way of doing this is to use dev.new() and pass
along the arguments you would have provided to the device via e.g.
windows():

dev.new(height = 6, width = 12)

HTH

G

> 
> > ?windows
> No documentation for 'windows' in specified packages and libraries:
> you could try '??windows'
> 
> 
> > window(width=12, height=6)
> Error in hasTsp(x) : 
>   element 1 is empty;
>    the part of the args list of 'attr' being evaluated was:
>    (x, "tsp")
> 
> 
> > ?window
> window {stats}
> http://stat.ethz.ch/R-manual/R-devel/library/stats/html/window.html
> 
> window                  package:stats                  R Documentation
> 
> Time Windows
> 
> Description:
> 
>      ‘window’ is a generic function which extracts the subset of the
>      object ‘x’ observed between the times ‘start’ and ‘end’. If a
>      frequency is specified, the series is then re-sampled at the new
>      frequency.
> 
> 
> > window(layout(matrix(1:2, nrow=1), width=12, height=6))
> [1] 2
> attr(,"tsp")
> [1] 1 1 1
> 
> 
> Still pop up a square window
> 
> 
> B.R
> Stephen L
> 
> 
> 
> 
> 
> ----- Original Message ----
> From: Greg Snow <Greg.Snow at imail.org>
> To: Stephen Liu <satimis at yahoo.com>; "r-help at r-project.org" 
> <r-help at r-project.org>
> Sent: Fri, August 27, 2010 10:51:21 AM
> Subject: RE: [R] About plot graphs
> 
> When you run any graphics command (layout in this case) and there is not a 
> current graphics device (more technically only the null device) then a default 
> graphics device is opened, that is what you are seeing.  What you need to do 
> instead is open the device yourself before calling layout.  Which device that is 
> depends greatly on information that the posting guide strongly suggests that you 
> provide (another hint).
> 
> One possibility is:
> 
> > windows(width=12, height=6) 
> 
> Followed by layout and the plotting commands.  But whether that will work on 
> your machine or not is still a bit of a mystery.
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at imail.org
> 801.408.8111
> 
> 
> > -----Original Message-----
> > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > project.org] On Behalf Of Stephen Liu
> > Sent: Thursday, August 26, 2010 8:02 PM
> > To: r-help at r-project.org
> > Subject: Re: [R] About plot graphs
> > 
> > Hi Greg,
> > 
> > Thanks for your advice.
> > 
> > I'm not prepared altering the shape of the graphs to be plotted.  What
> > I'm
> > trying to do is to pop up a rectangle layout window with following
> > command.
> > 
> > The command;
> > layout(matrix(1:2, nrow=1))
> > 
> > pop up a square window.  What I need is a rectangular window for the
> > graphs to
> > be plotted.  Otherwise the graphs are squeezed changing shape.
> > 
> > I looked at ?layout but can't resolve how to make it.  Can you help?
> > TIA
> > 
> > B.R.
> > Stephen L
> > 
> > 
> > 
> > 
> > ----- Original Message ----
> > From: Greg Snow <Greg.Snow at imail.org>
> > To: Stephen Liu <satimis at yahoo.com>; "r-help at r-project.org"
> > <r-help at r-project.org>
> > Sent: Fri, August 27, 2010 9:00:01 AM
> > Subject: RE: [R] About plot graphs
> > 
> > There is a graphical parameter that controls whether a plot is square
> > or takes
> > up the maximum amount of room (rectangle), see ?par and look at the
> > entry for
> > pty.
> > 
> > 
> > It is possible that you set pty='s' or it may be that the plot method
> > sets it,
> > without us knowing what type of object Date and Test01$Date are we
> > don't know
> > which method is creating your plot and cannot be much more help (that
> > is meant
> > as a subtle hint to provide the information requested in the footer of
> > every
> > post and the posting guide).
> > 
> > Some methods may set pty='s' as default but have an option to change
> > it.
> > 
> > --
> > Gregory (Greg) L. Snow Ph.D.
> > Statistical Data Center
> > Intermountain Healthcare
> > greg.snow at imail.org
> > 801.408.8111
> > 
> > 
> > > -----Original Message-----
> > > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > > project.org] On Behalf Of Stephen Liu
> > > Sent: Thursday, August 26, 2010 8:45 AM
> > > To: r-help at r-project.org
> > > Subject: [R] About plot graphs
> > >
> > > Hi folks,
> > >
> > > Following command prints 2 graphs side-by-side:-
> > > layout(matrix(1:2, nrow=1))
> > > plot(Date,Input_No.)
> > > plot(Test01$Date, Test01$Input_No.)
> > >
> > > However each is a square graph I need a rectangular layout.  Pls
> > advise
> > > how to
> > > make it.  TIA
> > >
> > > B.R.
> > > satimis
> > >
> > >
> > >
> > >
> > > ______________________________________________
> > > 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.
> > 
> > 
> > 
> > 
> > ______________________________________________
> > 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.
> 
> 
> 
> 
> ______________________________________________
> 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.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list