[R] split.screen to draw graphs - ggplot2 and lattice (can't slip in 4 cells)

Rosa Oliveira rosita21 at gmail.com
Sun Sep 6 16:06:56 CEST 2015


Dear all,

 

I need your urgent help J

 

I’m naïve, and I’m pretty sure my doubt is very simple to solve, but I’m not getting it.

 

I used the following code to produce my research graphs, nonetheless, is this problem, I do not have 6 graphs (1 – 6),

 

#   3   4   5

#                2

#   6   7   8

 

 

but only 4,instead.  So, I need to reformulate the code, just to

 

#   3   4  

#                2

#   6   7  

 

Can you please help me reformulating?

I suppose I have to change something in the split.screen code, because nowadays, my “third” column is blank J

 

 

I attach the code:

 

library(ggplot2)

library(reshape)

library(lattice)

 

mean.alpha1<-read.csv("graphs_mean_alpha1.csv")

mean.alpha2<-read.csv("graphs_mean_alpha2.csv")

quartz(width=10,height=5)

split.screen(figs=matrix(c(0,0.4,0.5,1,

                           0.4,0.7,0.5,1,

                           0.7,1,0.5,1,

                           0,0.4,0,0.5,

                           0.4,0.7,0,0.5,

                           0.7,1,0,0.5),nrow=6,byrow=TRUE),

             screen=1)

 

 

 

screen(3)

par(mar=c(0,3.5,3,0))

# now the second set

n250<-mean.alpha1$nsample==250

matplot(x=mean.alpha1$lambda[n250],y=mean.alpha1[n250,3:5],

        type="l",pch=1:3,col=c(4,2,3),xaxt="n",ylim=c(-1.2, -0.25),main="nsample=250",ylab="", cex.main=1)

abline(h = -1, col = "gray60")

mtext(expression(paste("mean av. for  ",alpha[1])),side=2,line=2, cex.main=1)

 

 

 

screen(4)

par(mar=c(0,0,3,0))

# now the second set

n250<-mean.alpha1$nsample==1000

matplot(x=mean.alpha1$lambda[n1000],y=mean.alpha2[n1000,3:5],

        type="l",pch=1:3,col=c(4,2,3),xaxt="n",yaxt="n",ylim=c(-1.2, -0.25),main="nsample=1000", cex.main=1)

abline(h = -1, col = "gray60")

 

 

 

screen(6)

par(mar=c(3,3.5,0,0))

# now the second set

n250<-mean.alpha2$nsample==250

matplot(x=mean.alpha2$lambda[n250],y=mean.alpha2[n250,3:5],

        type="l",pch=1:3,col=c(4,2,3),ylim=c(-.6, -.35),ylab="")

abline(h = -.5, col = "gray60")

mtext(expression(paste(lambda)),side=1,line=2, cex.main=1.5)

mtext(expression(paste("mean av. for  ",alpha[2])),side=2,line=2, cex.main=1.5)

 

 

 

screen(7)

par(mar=c(3,0,0,0))

# now the second set

n1000<-mean.alpha2$nsample==1000

matplot(x=mean.alpha2$lambda[n1000],y=mean.alpha2[n1000,3:5],

type="l",pch=1:3,col=c(4,2,3),yaxt="n",ylim=c(-.6, -.35))

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.", "true coefficient"),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