Re: [R] TeachingDemos question: my.symbols() alignment problems in complicated layout

2008-07-21 Thread maria
Hi Hadley and Paul,

thank you a lot for the suggestions...

However, i had also emailed Greg Snow  (author of my.symbols() function)
personally... and Greg has emailed me back with a fixed version of the
my.symbols() function -- to be included in the next release -- that works
without a hitch with layout()...

I am not posting it here, as i don't know if i am allowed...

Cheers,
Maria





 Here are a couple of options:

 (i)  use the 'gridBase' package and do these arrow annotations using the
 'grid' package, which allows you to control coordinate systems in a more
 rational manner.  There's an example (perhaps slightly more complicated
 than you need) in:
 http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

 (ii) draw your main plot using 'lattice' and the annotations using
 'grid' or possibly 'grImport'.  There's a hint of an example of the
 latter on slide 18 of:
 http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf

 (iii) draw the whole thing using 'grid'.  You can start to get
 acquainted with grid here:
 http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter5.pdf

 (iv) Use ggplot2 - particularly geom_segment
 (http://had.co.nz/ggplot2/geom_segment.html) and stat_spoke
 (http://had.co.nz/ggplot2/stat_spoke.html)

 Hadley

 --
 http://had.co.nz/


__
R-help@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.


Re: [R] TeachingDemos question: my.symbols() alignment problems in complicated layout

2008-07-21 Thread Greg Snow
The original poster also contacted me offline and now has a copy of my.symbols 
that works with layout (instead of resetting all the graphical parameters, it 
only resets the ones it changes).

The fixed version will be in the next release of the package, or anyone who 
would like a copy before then can e-mail me.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul Murrell
 Sent: Sunday, July 20, 2008 6:06 PM
 To: [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Subject: Re: [R] TeachingDemos question: my.symbols()
 alignment problems in complicated layout

 Hi


 [EMAIL PROTECTED] wrote:
  Hello,
 
  After usefull suggestions by Paul Murrell, i have been
 trying to use
  my.symbols to plot arrows of varying angles on my plot in order to
  create a time series of wind direction... however,i have
 been unable
  to figure out how the allignment of symbols works...
 
  below i have included a simplified code that illustrates my problem:
  (i am creating a .ps file ... so i've included this in my
 mock code,
  in case it might be part of the problem...)
 
  # TEST CODE
  #
 
  postscript(test.ps, horizontal=FALSE, width=7.5,
  height=11.5,pointsize=10, paper = special )
 
  library(TeachingDemos)
 
  opar - par(omi=c(0,0.1,0.7,0.1),xpd=T,mar=par()$mar+c(0,-1.5,-1,5))
 
  layout_mat = matrix(c(1,2,3,4),nrow=4,ncol=1,byrow=TRUE)
 
  my_layout -
 
 layout(layout_mat,widths=c(1,1,1,1),heights=c(1.0,0.45,1.0,1.2),respec
  t=FALSE)
 
  plot(1,1)
  plot(2,2)
  plot(3,3)
  plot(1:100,rep(c(9,1.5,2,8),25))
  points(40,4,col=red)
  points(50,8,col=red)
  my.symbols(40,4,ms.polygon,n=3,inches=0.2,add=TRUE)
  my.symbols(40,4,ms.arrows,angle=pi/2,inches=0.2,add=TRUE)
  my.symbols(50,8,ms.arrows,angle=pi/4,inches=0.2,add=TRUE)
  dev.off()
 
   END of TEST CODE
  ###
 
  If i look at the output test.ps ... the first symbol is
 exactly where
  i want it to be i.e. at x=40,y=4 ... while the position of the two
  other ones is offset by some mysterious(!!) value
 
  then if i comment out the first my.symbols(...) command...
 the second
  symbol is at the right place, while the third is offset ...etc
 
  However if i simply do:
 
  plot(1:100,rep(c(9,1.5,2,8),25))
  points(40,4,col=red)
  points(50,8,col=red)
  my.symbols(40,4,ms.polygon,n=3,inches=0.2,add=TRUE)
  my.symbols(40,4,ms.arrows,angle=pi/2,inches=0.2,add=TRUE)
  my.symbols(50,8,ms.arrows,angle=pi/4,inches=0.2,add=TRUE
 
 
  then everything is exactly where i want it ... suggesting
 there is a
  problem with the layout ???


 I think the issue is that my.symbols() does a lot of this ...

 op - par(no.readonly = TRUE)
 on.exit(par(op))

 ... which is not absolutely guaranteed to get you back to
 where you started (see the comment in the 'Value' section of
 the help page ?par).
Fixing that will need the cooperation of the author of
 TeachingDemos.

 Here are a couple of options:

 (i)  use the 'gridBase' package and do these arrow
 annotations using the 'grid' package, which allows you to
 control coordinate systems in a more rational manner.
 There's an example (perhaps slightly more complicated than
 you need) in:
 http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

 (ii) draw your main plot using 'lattice' and the annotations
 using 'grid' or possibly 'grImport'.  There's a hint of an
 example of the latter on slide 18 of:
 http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf

 (iii) draw the whole thing using 'grid'.  You can start to
 get acquainted with grid here:
 http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter5.pdf

 Unfortunately, all of these require a reasonable amount of
 extra learning on your part.

 Paul


  Any help would be really appreciated,
  Thank You a lot,
  maria
 
  __
  R-help@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 Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 [EMAIL PROTECTED]
 http://www.stat.auckland.ac.nz/~paul/

 __
 R-help@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@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

Re: [R] TeachingDemos question: my.symbols() alignment problems in complicated layout

2008-07-20 Thread Paul Murrell
Hi


[EMAIL PROTECTED] wrote:
 Hello,
 
 After usefull suggestions by Paul Murrell, i have been trying to use
 my.symbols to plot arrows of varying angles on my plot in order to create
 a time series of wind direction... however,i have been unable to figure
 out how the allignment of symbols works...
 
 below i have included a simplified code that illustrates my problem:
 (i am creating a .ps file ... so i've included this in my mock code, in
 case it might be part of the problem...)
 
 # TEST CODE #
 
 postscript(test.ps, horizontal=FALSE, width=7.5,
 height=11.5,pointsize=10, paper = special )
 
 library(TeachingDemos)
 
 opar - par(omi=c(0,0.1,0.7,0.1),xpd=T,mar=par()$mar+c(0,-1.5,-1,5))
 
 layout_mat = matrix(c(1,2,3,4),nrow=4,ncol=1,byrow=TRUE)
 
 my_layout -
 layout(layout_mat,widths=c(1,1,1,1),heights=c(1.0,0.45,1.0,1.2),respect=FALSE)
 
 plot(1,1)
 plot(2,2)
 plot(3,3)
 plot(1:100,rep(c(9,1.5,2,8),25))
 points(40,4,col=red)
 points(50,8,col=red)
 my.symbols(40,4,ms.polygon,n=3,inches=0.2,add=TRUE)
 my.symbols(40,4,ms.arrows,angle=pi/2,inches=0.2,add=TRUE)
 my.symbols(50,8,ms.arrows,angle=pi/4,inches=0.2,add=TRUE)
 dev.off()
 
  END of TEST CODE ###
 
 If i look at the output test.ps ... the first symbol is exactly where i
 want it to be i.e. at x=40,y=4 ... while the position of the two other
 ones is offset by some mysterious(!!) value
 
 then if i comment out the first my.symbols(...) command... the second
 symbol is at the right place, while the third is offset ...etc
 
 However if i simply do:
 
 plot(1:100,rep(c(9,1.5,2,8),25))
 points(40,4,col=red)
 points(50,8,col=red)
 my.symbols(40,4,ms.polygon,n=3,inches=0.2,add=TRUE)
 my.symbols(40,4,ms.arrows,angle=pi/2,inches=0.2,add=TRUE)
 my.symbols(50,8,ms.arrows,angle=pi/4,inches=0.2,add=TRUE
 
 
 then everything is exactly where i want it ... suggesting there is a
 problem with the layout ???


I think the issue is that my.symbols() does a lot of this ...

op - par(no.readonly = TRUE)
on.exit(par(op))

... which is not absolutely guaranteed to get you back to where you
started (see the comment in the 'Value' section of the help page ?par).
   Fixing that will need the cooperation of the author of TeachingDemos.

Here are a couple of options:

(i)  use the 'gridBase' package and do these arrow annotations using the
'grid' package, which allows you to control coordinate systems in a more
rational manner.  There's an example (perhaps slightly more complicated
than you need) in:
http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

(ii) draw your main plot using 'lattice' and the annotations using
'grid' or possibly 'grImport'.  There's a hint of an example of the
latter on slide 18 of:
http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf

(iii) draw the whole thing using 'grid'.  You can start to get
acquainted with grid here:
http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter5.pdf

Unfortunately, all of these require a reasonable amount of extra
learning on your part.

Paul


 Any help would be really appreciated,
 Thank You a lot,
 maria
 
 __
 R-help@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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.


Re: [R] TeachingDemos question: my.symbols() alignment problems in complicated layout

2008-07-20 Thread hadley wickham
 Here are a couple of options:

 (i)  use the 'gridBase' package and do these arrow annotations using the
 'grid' package, which allows you to control coordinate systems in a more
 rational manner.  There's an example (perhaps slightly more complicated
 than you need) in:
 http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

 (ii) draw your main plot using 'lattice' and the annotations using
 'grid' or possibly 'grImport'.  There's a hint of an example of the
 latter on slide 18 of:
 http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf

 (iii) draw the whole thing using 'grid'.  You can start to get
 acquainted with grid here:
 http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter5.pdf

(iv) Use ggplot2 - particularly geom_segment
(http://had.co.nz/ggplot2/geom_segment.html) and stat_spoke
(http://had.co.nz/ggplot2/stat_spoke.html)

Hadley

-- 
http://had.co.nz/

__
R-help@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] TeachingDemos question: my.symbols() alignment problems in complicated layout

2008-07-11 Thread maria
Hello,

After usefull suggestions by Paul Murrell, i have been trying to use
my.symbols to plot arrows of varying angles on my plot in order to create
a time series of wind direction... however,i have been unable to figure
out how the allignment of symbols works...

below i have included a simplified code that illustrates my problem:
(i am creating a .ps file ... so i've included this in my mock code, in
case it might be part of the problem...)

# TEST CODE #

postscript(test.ps, horizontal=FALSE, width=7.5,
height=11.5,pointsize=10, paper = special )

library(TeachingDemos)

opar - par(omi=c(0,0.1,0.7,0.1),xpd=T,mar=par()$mar+c(0,-1.5,-1,5))

layout_mat = matrix(c(1,2,3,4),nrow=4,ncol=1,byrow=TRUE)

my_layout -
layout(layout_mat,widths=c(1,1,1,1),heights=c(1.0,0.45,1.0,1.2),respect=FALSE)

plot(1,1)
plot(2,2)
plot(3,3)
plot(1:100,rep(c(9,1.5,2,8),25))
points(40,4,col=red)
points(50,8,col=red)
my.symbols(40,4,ms.polygon,n=3,inches=0.2,add=TRUE)
my.symbols(40,4,ms.arrows,angle=pi/2,inches=0.2,add=TRUE)
my.symbols(50,8,ms.arrows,angle=pi/4,inches=0.2,add=TRUE)
dev.off()

 END of TEST CODE ###

If i look at the output test.ps ... the first symbol is exactly where i
want it to be i.e. at x=40,y=4 ... while the position of the two other
ones is offset by some mysterious(!!) value

then if i comment out the first my.symbols(...) command... the second
symbol is at the right place, while the third is offset ...etc

However if i simply do:

plot(1:100,rep(c(9,1.5,2,8),25))
points(40,4,col=red)
points(50,8,col=red)
my.symbols(40,4,ms.polygon,n=3,inches=0.2,add=TRUE)
my.symbols(40,4,ms.arrows,angle=pi/2,inches=0.2,add=TRUE)
my.symbols(50,8,ms.arrows,angle=pi/4,inches=0.2,add=TRUE


then everything is exactly where i want it ... suggesting there is a
problem with the layout ???

Any help would be really appreciated,
Thank You a lot,
maria

__
R-help@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.