Santosh
2013-Jun-10 00:52 UTC
[R] Using Lattice, LatticeExtra - Hide right and top axes in multipanel plots
Dear Rxperts,
How do I hide the top and right axes in multiple panel plots? A couple of
examples are provided below.. Would highly appreciate appreciate your
assistance..
#Example 1
library(latticeExtra)
xyplot((1:200)/20 ~ (1:200)/20, type = c("p", "g"),
scales = list(x = list(log = 2,alternating=0), y = list(log 10,alternating=0)),
xscale.components = xscale.components.log10ticks,
yscale.components = yscale.components.log10ticks,top=F,right=F)
#Example 2
q <-
data.frame(G=rep(paste("G",1:3,sep=""),each=50),D=rep(paste("D",1:5,sep=""),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20)))
q$grp <- paste(q$D,q$a,sep=":")
q$grp <- ordered(q$grp, levels=unique(q$grp))
q$dcol <- unlist(sapply(q$D,function(x)
switch(x,"D1"="orange","D2"="blue","D3"="red",
"D4"="seagreen",
"D5"="black")))
q2 <- q[order(q$G,q$D,q$a,q$t),]
xyplot(b~t|G,data=q2,groups=grp,type="l",as.table=T,
layout=c(3,1), par.strip.text = list(lines = 2),
scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)),
panel=panel.superpose,
panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number)
{
require(grid)
panel.axis(side="top",labels = F,draw.labels = F,ticks =
F,line.col=NA,
line.lty=NA, line.lwd=0, line.alpha=0)
panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type="l",
col=q2$dcol[subscripts],lty=1,cex=0.7)
},
strip=F,
#
strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,
var.name="School"),
xlab="t",
ylab="b",
main="Overlay of Profiles by Schools and Classes",
)
Thanks so much,
Santosh
[[alternative HTML version deleted]]
Santosh
2013-Jun-10 01:04 UTC
[R] Using Lattice, LatticeExtra - Hide right and top axes in multipanel plots
I updated the code for the second example.. This time.. all the axes
disappeared!!
xyplot(b~t|G,data=q2,groups=grp,type="l",as.table=T,
layout=c(3,1), par.settings=list(axis.line=list(col=0)),
scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)),
panel=panel.superpose,
panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number)
{
require(grid)
panel.axis(side="top",labels = F,draw.labels = F,ticks =
F,line.col=NA,
line.lty=NA, line.lwd=0, line.alpha=0)
panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type="l",
col=q2$dcol[subscripts],lty=1,cex=0.7)
},
strip=F,
#
strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,
var.name="School"),
xlab="t",
ylab="b",
main="Overlay of Profiles by Schools and Classes",
)
On Sun, Jun 9, 2013 at 5:52 PM, Santosh <santosh2005@gmail.com> wrote:
> Dear Rxperts,
> How do I hide the top and right axes in multiple panel plots? A couple of
> examples are provided below.. Would highly appreciate appreciate your
> assistance..
>
> #Example 1
> library(latticeExtra)
> xyplot((1:200)/20 ~ (1:200)/20, type = c("p", "g"),
> scales = list(x = list(log = 2,alternating=0), y = list(log >
10,alternating=0)),
> xscale.components = xscale.components.log10ticks,
> yscale.components = yscale.components.log10ticks,top=F,right=F)
>
> #Example 2
> q <-
>
data.frame(G=rep(paste("G",1:3,sep=""),each=50),D=rep(paste("D",1:5,sep=""),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20)))
> q$grp <- paste(q$D,q$a,sep=":")
> q$grp <- ordered(q$grp, levels=unique(q$grp))
> q$dcol <- unlist(sapply(q$D,function(x)
>
switch(x,"D1"="orange","D2"="blue","D3"="red",
"D4"="seagreen",
> "D5"="black")))
> q2 <- q[order(q$G,q$D,q$a,q$t),]
> xyplot(b~t|G,data=q2,groups=grp,type="l",as.table=T,
> layout=c(3,1), par.strip.text = list(lines = 2),
>
>
scales=list(x=list(rela='free',alternating=0),y=list(rela='free',alternating=0),col=1,tck=c(1,0)),
> panel=panel.superpose,
>
panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number)
> {
> require(grid)
> panel.axis(side="top",labels = F,draw.labels = F,ticks =
F,line.col=NA,
> line.lty=NA, line.lwd=0, line.alpha=0)
>
panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type="l",
> col=q2$dcol[subscripts],lty=1,cex=0.7)
> },
> strip=F,
> #
>
strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,
> var.name="School"),
> xlab="t",
> ylab="b",
> main="Overlay of Profiles by Schools and Classes",
> )
>
>
> Thanks so much,
> Santosh
>
[[alternative HTML version deleted]]