[R] HELP IN GRAPHS - slip screen

Rosa Oliveira rosita21 at gmail.com
Wed Sep 16 18:45:09 CEST 2015


Dear all,

I’m trying to do a graph, 

3 rows, 5 columns, with the design:
#   3   4   5   6 
#                    2
#   7   8   9   10 

I had a code for 3 rows, 3 columns, with the design::
#   3   4   
#            2
#   7   8    
 and I tried to modify it, but I had no success :(

I suppose the problem is in the slip.screen code (red part of the code).

I attach my code, can anyone please help me?


Best,
RO


setwd("/Users/RO/Dropbox/LMER - 3rdproblem/R/latest_version/graphs/data")

library(ggplot2)
library(reshape)
library(lattice)


# read in what looks like half of the data

bias.alpha2<-read.csv("graphs_bias_alpha2.csv")
SE.alpha2<-read.csv("graphs_SE_alpha2.csv")
bias.alpha1<-read.csv("graphs_bias_alpha1.csv")
SE.alpha1<-read.csv("graphs_SE_alpha1.csv")



quartz(width=10,height=6)
# do the first split, to get the rightmost screen for the legend
split.screen(figs=matrix(c(0,0.8,0,1,0.8,1,0,1),nrow=2,byrow=TRUE))
# now split the first screen to get your six screens for the plots



split.screen(figs=matrix(c(0,0.5,0.5,1,#primeira linha primeira coluna
                           0.5,1,0.5,1,#primeira linha segunda coluna
                           0,0.5,0,0.5,#segunda linha primeira coluna
                           0.5,1,0,0.5),#segunda linha segunda coluna
                         ncol=4,byrow=TRUE),screen=1)


# this produces seven screens numbered like this:
#   3   4   5   6 
#                    2
#   7   8   9   10 
# select the upper left screen



screen(3)
par(mar=c(0,3.5,3,0))
# now the second set
n250<-bias.alpha1$nsample==250
matplot(x=bias.alpha1$lambda[n250],y=bias.alpha1[n250,3:5],
        type="l",pch=1:3,col=c(4,2,3),xaxt="n",ylim=c(-.1, .6),main="nsample=250",ylab="", cex.main=1)
abline(h = 0, col = "gray60")
mtext(expression(paste("Bias av. for  ",alpha[1])),side=2,line=2, cex.main=1)

screen(4)
par(mar=c(0,0,3,0))
# now the second set
n1000<-bias.alpha1$nsample==1000
matplot(x=bias.alpha1$lambda[n1000],y=bias.alpha1[n1000,3:5],
        type="l",pch=1:3,col=c(4,2,3),xaxt="n",yaxt="n",ylim=c(-.1, .6),main="nsample=1000",ylab="")
abline(h = 0, col = "gray60")



screen(5)
par(mar=c(0,3.5,3,0))
# now the second set
par(mar=c(3,3.5,0,0))
# now the second set
n250<-bias.alpha2$nsample==250
matplot(x=bias.alpha2$lambda[n250],y=bias.alpha2[n250,3:5],
        type="l",pch=1:3,col=c(4,2,3),ylim=c(-.1, .6),ylab="")
abline(h = 0, col = "gray60")
mtext(expression(paste("Bias av. for  ",alpha[2])),side=2,line=2, cex.main=1.5)

screen(6)
par(mar=c(3,0,0,0))
# now the second set
n1000<-bias.alpha2$nsample==1000
matplot(x=bias.alpha2$lambda[n1000],y=bias.alpha2[n1000,3:5],
        type="l",pch=1:3,col=c(4,2,3),yaxt="n",ylim=c(-.1, .6))
abline(h = 0, col = "gray60")




screen(7)
par(mar=c(0,3.5,3,0))
# now the second set
n250<-SE.alpha1$nsample==250
matplot(x=SE.alpha1$lambda[n250],y=SE.alpha1[n250,3:5],
        type="l",pch=1:3,col=c(4,2,3),xaxt="n",ylim=c(0, 1.1),main="nsample=250",ylab="", cex.main=1)
abline(h = -1, col = "gray60")
mtext(expression(paste("SE av. for  ",alpha[1])),side=2,line=2, cex.main=1)
mtext(expression(paste(lambda)),side=1,line=2, cex.main=1.5)


screen(8)
par(mar=c(0,0,3,0))
# now the second set
n1000<-SE.alpha1$nsample==1000
matplot(x=SE.alpha1$lambda[n1000],y=SE.alpha1[n1000,3:5],
        type="l",pch=1:3,col=c(4,2,3),xaxt="n",yaxt="n",ylim=c(0, 1.1),main="nsample=1000",ylab="")
abline(h = -1, col = "gray60")




screen(9)
par(mar=c(3,3.5,0,0))
# now the second set
n250<-SE.alpha2$nsample==250
matplot(x=SE.alpha2$lambda[n250],y=SE.alpha2[n250,3:5],
        type="l",pch=1:3,col=c(4,2,3),ylim=c(0, 1.1),ylab="")
abline(h = -.5, col = "gray60")
mtext(expression(paste("SE av. for  ",alpha[2])),side=2,line=2, cex.main=1.5)
mtext(expression(paste(lambda)),side=1,line=2, cex.main=1.5)


screen(10)
par(mar=c(3,0,0,0))
# now the second set
n1000<-SE.alpha2$nsample==1000
matplot(x=SE.alpha2$lambda[n1000],y=SE.alpha2[n1000,3:5],
        type="l",pch=1:3,col=c(4,2,3),yaxt="n",ylim=c(0, 1.1))
abline(h = -.5, col = "gray60")
mtext(expression(paste(lambda)),side=1,line=2, , cex.main=1.5)



screen(2)
par(mar=c(0,0,0,0))
# plot an empty plot to get the coordinates
plot(0:1,0:1,type="n",axes=FALSE)
legend(0,0.6,c("OLS", "GLS", "Reg. Cal.", "0"),bty = "n", lty=1:3,col=c(4,2,3,"gray60"),xpd=TRUE)


close.screen(all=TRUE)




Best,
RO


Atenciosamente,
Rosa Oliveira

-- 
____________________________________________________________________________


Rosa Celeste dos Santos Oliveira, 

E-mail: rosita21 at gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira
____________________________________________________________________________
"Many admire, few know"
Hippocrates



More information about the R-help mailing list