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

From: <maria_at_meteo.mcgill.ca>
Date: Fri, 11 Jul 2008 11:30:19 -0400 (EDT)


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_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 Fri 11 Jul 2008 - 15:34:54 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 Mon 21 Jul 2008 - 01:32:24 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