[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]] __ R-help@r-project.org mailing list 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.
Re: [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 santosh2...@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]] __ R-help@r-project.org mailing list 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.
Re: [R] Using Lattice, LatticeExtra - Hide right and top axes in multipanel plots
Hi You had to references to strip The axis.line in the par settings removes the axis line Have made some slight changes to your code which may be of interest I keep the panel arguments last and so avoid duplication require(grid) xyplot(b~t|G,data=q2,groups=grp, type=l, aspect = 1, as.table=T, layout=c(3,1), xlab=t, ylab=b, main=Overlay of Profiles by Schools and Classes, par.settings=list(layout.heights = list(strip =2), axis.line=list(col=0)), strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,var.name=School), 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){ panel.axis(side=top,labels = F,draw.labels = F,ticks = F, line.lwd=0, line.alpha=0) panel.xyplot(x=x,y=y,subscripts=subscripts, lwd=1,type=l, col=q2$dcol[subscripts], lty=1, cex=0.7) } ) Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au At 11:04 10/06/2013, you wrote: 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 santosh2...@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]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.