[R] About plot graphs

Stephen Liu satimis at yahoo.com
Fri Aug 27 06:01:06 CEST 2010


Hi Greg,


Test01 was created with;

> Test01=read.table(file=file.choose(), header=TRUE)

the file selected was a .txt file.

Day    Month    Mo.Number    Day_of_year    Draft_No.
1    Jan    1    1    305
2    Jan    1    2    159
3    Jan    1    3    251
4    Jan    1    4    215
......
1    Feb    2    32    86
2    Feb    2    33    144
3    Feb    2    34    297
4    Feb    2    35    210
5    Feb    2    36    214
etc.


> windows(width=12, height=6)
Error: could not find function "windows"


> ?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.






More information about the R-help mailing list