[R] TeachingDemos question: my.symbols() alignment problems in complicated layout
maria at meteo.mcgill.ca
maria at meteo.mcgill.ca
Fri Jul 11 17:30:19 CEST 2008
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
More information about the R-help
mailing list