The development version of the lattice package has a 'ylab.right' option, so you can do something like this to place your y labels:
xyplot(1:10 ~ 1:10 | c('a','b'), layout = c(1,2), ylab = list("label one", y = 0.75), ylab.right = list("label two", y = 0.25, rot = 270)) For the row-specific panel scales, again there is the new combineLimits() function. Regards # Felix On 1 September 2010 06:40, Kay Cichini <kay.cich...@uibk.ac.at> wrote: > > ...after digging for a while now, i came to a solution which may be crude, > but it works perfectly well. > if someone would advise me how to use textGrob avoiding the "\n" in the > title, combined with the linewidth = 4 in gpar(), to put the axis title into > the right place i'd be very glad! > > maybe there is a better way to do it with latticeExtra (doubleYScale()?,..) > but i could not find one. > > library(lattice) > > y1 <- rnorm(120,100,10) > y2 <- rnorm(120,10,1) > facs<-expand.grid(Sites=rep(c("Site I","Site II","Site > III"),20),Treatment=c("A","B")) > > trellis.par.set(clip=list(panel="off",strip="off"), > layout.widths=list(ylab.axis.padding=0)) ### adjusts > same space to both sides of device > > PanFun<-function(...){ > panel.dotplot(...) > if(is.element(panel.number(),1:2)) > {at<-pretty(range(y1)) > panel.axis("right",at=at,outside=T, > labels = F,half=F)} > if(panel.number() == 3) > {at<-pretty(range(y1)) > panel.axis("right",at=at,outside=T, > labels = T,half=F)} > if(panel.number() == 4) > {at<-pretty(range(y2)) > panel.axis("left",at=at,outside=T, > labels = T,half=F)} > if(is.element(panel.number(),5:6)) > {at<-pretty(range(y2)) > panel.axis("left",at=at,outside=T, > labels = F,half=F)} > } > > library(grid) > > g1<-textGrob("\ny1 response naxis title", x = unit(0.5, "npc"), y = > unit(0.25,"npc"), ### crude1 > just = "centre", hjust = NULL, vjust = 0, rot = 270, > check.overlap = FALSE, default.units = "npc", > name = NULL, gp = gpar(lineheight=4), vp = NULL) > ### crude2 > > g2<-textGrob("\ny2 response axis title", x = unit(0.5, "npc"), y = > unit(0.75,"npc"), > just = "centre", hjust = NULL, vjust = 0, rot = 90, > check.overlap = FALSE, default.units = "npc", > name = NULL, gp = gpar(lineheight=4), vp = NULL) > > dotplot(y1+y2 ~ Treatment|Sites, > outer=TRUE,data=facs, > scales = list( > x = list(rot = 0, tck=c(1,0)), > y = list(draw=F,relation="free", > limits=list(range(y1),range(y1),range(y1), > range(y2),range(y2),range(y2)))), > ylab=NULL,xlab=c("Site 1", "Site 2","Site 3"), > strip=FALSE, panel=PanFun, > legend = > list(right = list(fun = g1), > left = list(fun = g2))) > > > quote original: > > ... i added relation="free" to account for diffferent ranges of y1 and y2: > > dotplot(y1+y2 ~ facs$Treatment|facs$Sites, > outer=TRUE, > scales = list(y = list(relation="free"), x = list(rot = 90, > tck=c(1,0))), > ylab=c("y1", "y2"), > xlab=c("Site 1", "Site 2"), > strip=FALSE) > > but then i get four different y-lims. > more suited there should be only two - one for each response. > can someone tell me how i have to change the code? > > best, > kay > > > >> Kay, >> >> doe this do what you want? >> >> >> dotplot(y1+y2 ~ facs$Treatment|facs$Sites, >> outer=TRUE, >> scales = list(x = list(rot = 90, tck=c(1,0))), >> ylab=c("y1", "y2"), >> xlab=c("Site 1", "Site 2"), >> strip=FALSE) >> >> >> On Wed, Aug 25, 2010 at 11:04 AM, Kay Cichini >> <kay.cich...@uibk.ac.at>wrote: >> >>> >>> hello, >>> >>> i want to stack two lattice plots beneath each other using one x-axis and >>> sharing the same text-panels, >>> like: >>> ##################################################################### >>> library(lattice) >>> >>> y1 <- rnorm(100,100,10) >>> y2 <- rnorm(100,10,1) >>> facs<-expand.grid(Sites=rep(c("Site I","Site >>> II"),25),Treatment=c("A","B")) >>> pl1<-dotplot(y1 ~ facs$Treatment|facs$Sites, >>> scales = list(x = list(rot = 90, tck=c(1,0)))) >>> pl2<-dotplot(y2 ~ facs$Treatment|facs$Sites, >>> scales = list(x = list(rot = 90, tck=c(1,0)))) >>> >>> print(pl1, split=c(1,2,1,2), more=TRUE) >>> print(pl2, split=c(1,1,1,2)) >>> ##################################################################### >>> >>> but as said, ideally the plots should be stacked with only the lower plot >>> giving the x-axis annotation >>> and only the upper plot with text-panels. >>> >>> thanks a lot, >>> kay >>> >>> ----- >>> ------------------------ >>> Kay Cichini >>> Postgraduate student >>> Institute of Botany >>> Univ. of Innsbruck >>> ------------------------ > > ----- > ------------------------ > Kay Cichini > Postgraduate student > Institute of Botany > Univ. of Innsbruck > ------------------------ > > -- > View this message in context: > http://r.789695.n4.nabble.com/lattice-help-required-tp2338382p2402285.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ ______________________________________________ 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.