[R] HELP IN GRAPHS - slip screen (URGENT)
Rosa Oliveira
rosita21 at gmail.com
Sun Sep 20 18:14:20 CEST 2015
Dear Jim,
I’ve tried till today, but I could not solve the problems.
1. despite the scales are the same (equal: lambda ={0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 0.98}), the "matrix" is not equal. If you see, for n = 250 the column is narrower than for n = 1000, and "lambda" has the same values.
2. the first 2 columns relate to alpha 1 and the second two columns alpha2. Is it possible to place a title above nsample that concerns the first 2 columns and other over the last 2?
something like:
alpha1 alpha2
nsample=250 nsample=1000 nsample=250 nsample=1000
3. Notice that have 4 separate drawings and must place the 4 "groups" together.
Can you help?
It's really important.
Best,
RO
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),xaxt="n",yaxt="n",ylim=c(-.1, .6),main="nsample=250",ylab="")
abline(h = 0, col = "gray60")
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),xaxt="n",yaxt="n",ylim=c(-.1, .6),main="nsample=1000",ylab="")
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),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),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),yaxt="n",ylim=c(0, 1.1),ylab="")
abline(h = -.5, col = "gray60")
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),ylab="")
abline(h = -1, 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)
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
> On 18 Sep 2015, at 10:38, Jim Lemon <drjimlemon at gmail.com> wrote:
>
> Hi Rosa,
> I have had a moment to look at your code. First I think you should start your device as:
>
> quartz(width=12,height=5)
>
> The split.screen code that I sent seems to work for me, giving the
>
> 3 4 5 6
> 2
> 7 8 9 10
>
> layout of screens. To get the aspect ratio of the plots more similar, 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.31,0.5,1,
> 0.31,0.54,0.5,1,
> 0.54,0.77,0.5,1,
> 0.77,1,0.5,1,
> 0,0.31,0,0.5,
> 0.31,0.54,0,0.5,
> 0.54,0.77,0,0.5,
> 0.77,1,0,0.5),
> ncol=4,byrow=TRUE),screen=1)
>
> I'm not sure of which plots should go on the top line and which on the bottom, but I think you want margins like this:
>
> screen(3)
> par(mar=c(0,3.5,3,0))
> screen(4)
> par(mar=c(0,0,3,0))
> screen(5)
> par(mar=c(0,0,3,0))
> screen(6)
> par(mar=c(0,0,3,0))
> screen(7)
> par(mar=c(3,3.5,0,0))
> screen(8)
> par(mar=c(3,0,3,0))
> screen(9)
> par(mar=c(3,0,3,0))
> screen(10)
> par(mar=c(3,0,3,0))
>
> Perhaps this will help.
>
> Jim
>
>
> On Fri, Sep 18, 2015 at 6:14 AM, Jim Lemon <drjimlemon at gmail.com <mailto:drjimlemon at gmail.com>> wrote:
> Hi Rosa,
> I don't think the problem is with the split.screen command, for you are getting the eight plots and the screen at the right as you requested. It looks like your margins for each plot need adjusting, and I also think you should have about a 2.2 to 1 width to height ratio in the graphics device. I can't analyze the rest of the code at the moment, but perhaps tomorrow if you can't work it out I can provide some suggestions.
>
> Jim
>
>
> On Fri, Sep 18, 2015 at 1:16 AM, Rosa Oliveira <rosita21 at gmail.com <mailto:rosita21 at gmail.com>> wrote:
> 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 <mailto: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 <mailto: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 <mailto:rosita21 at gmail.com>
> Tlm: +351 939355143 <tel:%2B351%20939355143>
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira <https://pt.linkedin.com/in/rosacsoliveira>
> ____________________________________________________________________________
> "Many admire, few know"
> Hippocrates
>
> ______________________________________________
> R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
More information about the R-help
mailing list