[R] HELP IN GRAPHS - slip screen

Rosa Oliveira rosita21 at gmail.com
Thu Sep 17 17:16:47 CEST 2015


Dear Jim,

It works, nonetheless, it doesn't slip the screen correctly :(

Do you have any idea?


I used the code:


#setwd("/Users/RO/Dropbox/LMER - 3rdproblem/R/latest_version/graphs/data")
setwd("~/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.84,0,1,0.84,1,0,1),nrow=2,byrow=TRUE))
# now split the first screen to get your eight screens (numbered 3 to 10)
for the plots
split.screen(figs=matrix(c(0,0.25,0.5,1,
                           0.25,0.5,0.5,1,
                           0.5,0.75,0.5,1,
                           0.75,1,0.5,1,
                           0,0.25,0,0.5,
                           0.25,0.5,0,0.5,
                           0.5,0.75,0,0.5,
                           0.75,1,0,0.5),
                         ncol=4,byrow=TRUE),screen=1)



#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)


and I attach the output graph.



Best,
RO

Atenciosamente,
Rosa Oliveira

_________________________________

Antes de imprimir este e-mail pense bem se tem mesmo que o fazer.
Há cada vez menos árvores.
Não imprima, pense na sua responsabilidade e compromisso com o MEIO
AMBIENTE!
<http://pt.dreamstime.com/cora-ccedil-atildeo-criado-das-folhas-de-aacutervores-diferentes-thumb12275776.jpg>
<http://pt.dreamstime.com/cora-ccedil-atildeo-criado-das-folhas-de-aacutervores-diferentes-thumb12275776.jpg>

2015-09-17 12:18 GMT+01:00 Jim Lemon <drjimlemon at gmail.com>:

> Hi Rosa,
> Try this:
>
> # do the first split, to get the rightmost screen for the legend
> split.screen(figs=matrix(c(0,0.84,0,1,0.84,1,0,1),nrow=2,byrow=TRUE))
> # now split the first screen to get your eight screens (numbered 3 to 10)
> for the plots
> split.screen(figs=matrix(c(0,0.25,0.5,1,
>                            0.25,0.5,0.5,1,
>                            0.5,0.75,0.5,1,
>                            0.75,1,0.5,1,
>                            0,0.25,0,0.5,
>                            0.25,0.5,0,0.5,
>                            0.5,0.75,0,0.5,
>                            0.75,1,0,0.5),
>                          ncol=4,byrow=TRUE),screen=1)
>
> Jim
>
>
> On Thu, Sep 17, 2015 at 2:45 AM, Rosa Oliveira <rosita21 at gmail.com> wrote:
>
>> 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
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compare_8.pdf
Type: application/pdf
Size: 396551 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150917/1b3594ae/attachment.pdf>


More information about the R-help mailing list