Dear Rxperts,
Using the above example, I have been playing around using viewport under
"panel-function(...) {...}" block in conjunction with
"panel.groups=function(..) {xyplot.}" code block.. I have not bee
successful so far.. I was wondering if it is possible to pass user-defined
functions (including data driven text annotations) in both "panel" and
"panel.groups" arguments?

Thanks so much..
Santosh


On Tue, May 21, 2013 at 10:04 PM, Santosh <santosh2...@gmail.com> wrote:

> Dear Rxperts,
> Sorry about that..forgot to update the numeric part of the multipanel
> group indicator...
>
> Below is the updated code... in addition to getting rid of the curly
> braces, is there a better way to control the position of
> panel.text flexibly instead of hardcoding.
>
> Thanks,
> santosh
>
> q <- data.frame(GL = rep(paste("G",1:3,sep = ""),each = 50),
> G  = rep(1:3,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),]
> ref3 <-  subset(q2, !duplicated(a))
> my.theme = list(strip.border = list(col = NA),
> strip.background = list(col = NA)) # Of course, I can add a series of
> "$".. I don't have too many "$"s!
>
> xyplot(b ~ t | G,data = q2,groups = grp,type = "l",as.table = T,
>     layout = c(3,1), par.strip.text = list(lines = 2),
>     panel = panel.superpose,
> par.settings = my.theme,
>  panel.groups = function(x = x,
> y = y,
> subscripts = subscripts,
>  groups = groups,...,
> group.number) {
>         require(grid)
>         panel.xyplot(x = x,y = y,
>  subscripts = subscripts,pch = NA,lwd = 1,type = "l",
>                         col = q2$dcol[subscripts],lty = 1,cex = 0.7)
>          rv0    <- ref3[ref3$G%in%unique(q2$G)[panel.number()],]
>  panel.text(x=5,y=15,label=unique(rv0$GL))
>          tids   <-  paste(as.character(unique(rv0$D)))
>         tcols   <-  unique(rv0$dcol)
>         tlty    <-  1
> draw.key(list(columns = 1,between = 1,between.col = 0.5,
>             text = list(lab = tids,col = tcols,cex = 0.8),title =
> "Classes",cex.title = 1.1
>  ),
>         draw  =  T,vp  =  viewport(x  =  unit(0.8, "npc"), y  =  unit(0.9,
> "npc")))
>      },
>      strip = strip.custom(strip.names = T,strip.levels = T,par.strip.text
> = list(cex = 1.7,font = 2),bg = 0,var.name = "School"),
>         xlab = deparse(substitute(x)),
>         ylab = deparse(substitute(y)),
>         main = "Overlay of Profiles by Schools and Classes",
> )
>
>
>
> On Tue, May 21, 2013 at 8:21 PM, David Winsemius 
> <dwinsem...@comcast.net>wrote:
>
>>
>> On May 21, 2013, at 5:07 PM, Santosh wrote:
>>
>> > Dear Rxperts,
>> > Ok.... The "curly braces" as we talked before,...
>> > They appear if the "group" argument of "xyplot" function is entered as a
>> > numeric value; and don't when the values are letters.
>>
>> At the moment you are offering an example where the group argument is
>> neither numeric, nor character, but rather is a factor-classed variable. I
>> cannot make any curley items appear if I change the argument to numeric.
>>
>> On my machine (a Mac running R 3.0.0 RC) there are no curley braces ...
>> on the strips (or anywhere else.)
>>
>> I do not know what you mean by "keep only side 1 and 2 of the borders".
>> It is possible that you want to avoid alternating tick labels and need to
>> find the switch to suppress ticks labels on the upper and right sides of
>> the plotting borders. Try:
>>
>> ?xyplot  # scales section
>>
>> … scales=list(alternating=c(1,1,1) ),  # 1 choice repeated for the number
>> of columns
>>
>> --
>> David.
>>
>> > I just figured how to hide the strip borders...and also control the
>> ticks
>> > in different axes...
>> >
>> > Any suggestions to remove the *curly braces* are highly welcome.
>> >
>> >
>> > 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),]
>> > ref3 <-  subset(q2, !duplicated(a))
>> > my.theme = list(strip.border = list(col = NA),
>> > strip.background = list(col = NA)) # Of course, I can add a series of
>> "$"..
>> > I don't have too many "$"s!
>> >
>> > xyplot(b ~ t | G,data = q2,groups = grp,type = "l",as.table = T,
>> >    layout = c(3,1), par.strip.text = list(lines = 2),
>> >    panel = panel.superpose,
>> > par.settings = my.theme,
>> > panel.groups = function(x = x,
>> > y = y,
>> > subscripts = subscripts,
>> > groups = groups,...,
>> > group.number) {
>> >        require(grid)
>> >        panel.xyplot(x = x,y = y,
>> > subscripts = subscripts,pch = NA,lwd = 1,type = "l",
>> >                        col = q2$dcol[subscripts],lty = 1,cex = 0.7)
>> >         rv0    <- ref3[ref3$G%in%unique(q2$G)[panel.number()],]
>> >         tids   <-  paste(as.character(unique(rv0$D)))
>> >        tcols   <-  unique(rv0$dcol)
>> >        tlty     <-  1
>> > draw.key(list(columns = 1,between = 1,between.col = 0.5,
>> >            text = list(lab = tids,col = tcols,cex = 0.8),title =
>> > "Classes",cex.title = 1.1
>> > ),
>> >        draw  =  T,vp  =  viewport(x  =  unit(0.8, "npc"), y  =
>>  unit(0.9,
>> > "npc")))
>> >    },
>> >     strip = strip.custom(strip.names = T,strip.levels =
>> T,par.strip.text =
>> > list(cex = 1.7,font = 2),bg = 0,var.name = "School"),
>> >        xlab = deparse(substitute(x)),
>> >        ylab = deparse(substitute(y)),
>> >        main = "Overlay of Profiles by Schools and Classes",
>> > )
>> >
>> >
>> > On Tue, May 21, 2013 at 3:00 PM, Santosh <santosh2...@gmail.com> wrote:
>> >
>> >> Dear Rxperts,
>> >>
>> >> Using the same example above, is there a way to remove the borders of
>> >> multi-panel strips and control the display of the  borders of each
>> panel..
>> >> for example, I would like to keep only side 1 & 2 of a panel...
>> >>
>> >> Thanks,
>> >> Santosh
>> >>
>> >>
>> >>
>> >>
>> >> On Wed, May 1, 2013 at 11:11 PM, Santosh <santosh2...@gmail.com>
>> wrote:
>> >>
>> >>> Thanks for all tips/suggestions..  Just a few more comments..
>> >>> The same code I use with a different data set in another project does
>> not
>> >>> create those curly braces!
>> >>>
>> >>> Regards,
>> >>> Santosh
>> >>>
>> >>>
>> >>> On Wed, May 1, 2013 at 8:16 PM, Santosh <santosh2...@gmail.com>
>> wrote:
>> >>>
>> >>>> Sorry about the word "brackets".. Yes, I meant curly  braces! I have
>> not
>> >>>> heard of "curley braces"! :).  Curly braces surrounding the values of
>> >>>> "strip.levels" appear on the strip of multipanel plots.
>> >>>>
>> >>>> Thanks,
>> >>>> Santosh
>> >>>>
>> >>>>
>> >>>> On Wed, May 1, 2013 at 7:44 PM, David Winsemius <
>> dwinsem...@comcast.net>wrote:
>> >>>>
>> >>>>>
>> >>>>> On May 1, 2013, at 6:16 PM, Santosh wrote:
>> >>>>>
>> >>>>>> Dear Rxperts,
>> >>>>>
>> >>>>>> I have a strange situation.. I see curly brackets
>> >>>>>
>> >>>>> Wait right here. What do you mean by "brackets"? In some locales,
>> such
>> >>>>> as mine,  that might mean "[" ; in other domains... well,  who
>> knows? I
>> >>>>> don't see any "[".
>> >>>>>
>> >>>>> The Urban Legends Newsgroup used to have a saying: TWIAVBP,  which
>> is
>> >>>>> an initialism for: The World Is A Very Big Place. Pleas realize that
>> >>>>> language is local.
>> >>>>>
>> >>>>>> around "strip.levels" in
>> >>>>>> multipanel strips while using lattice::xyplot. .How do I get rid of
>> >>>>> the
>> >>>>>> curly brackets?
>> >>>>>
>> >>>>> Curly "brackets"? You mean curley braces? I see some of them in the
>> >>>>> code, but why in the world would one want to remove valid
>> curley-braces in
>> >>>>> code? They just function as delimiters.
>> >>>>>
>> >>>>>
>> >>>>>> For some reason, I am not able to reproduce the problem
>> >>>>>> using an example below...
>> >>>>>
>> >>>>> What problem?  .. are you unable to reproduce? The code runs without
>> >>>>> error on my machine.
>> >>>>>
>> >>>>>
>> >>>>>> Any suggestions are highly welcome!
>> >>>>>> Thanks,
>> >>>>>> Santosh
>> >>>>>>
>> >>>>>> 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),]
>> >>>>>> ref3 <- subset(q2, !duplicated(a))
>> >>>>>> xyplot(b~t|G,data=q2,groups=grp,type="l",as.table=T,
>> >>>>>>   layout=c(3,1), par.strip.text = list(lines = 2),
>> >>>>>>   panel=panel.superpose,
>> >>>>>>
>> >>>>>
>> panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number)
>> >>>>>> {
>> >>>>>>       require(grid)
>> >>>>>>
>> >>>>> panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type="l",
>> >>>>>>                       col=q2$dcol[subscripts],lty=1,cex=0.7)
>> >>>>>>        rv0     <-ref3[ref3$G%in%unique(q2$G)[panel.number()],]
>> >>>>>>        tids    <- paste(as.character(unique(rv0$D)))
>> >>>>>>       tcols   <- unique(rv0$dcol)
>> >>>>>>       tlty    <- 1
>> >>>>>> draw.key(list(columns=1,between=1,between.col=0.5,
>> >>>>>>
>> >>>>>> text=list(lab=tids,col=tcols,cex=0.8),title="Classes",cex.title=1.1
>> >>>>>> ),
>> >>>>>>       draw = T,vp = viewport(x = unit(0.8, "npc"), y = unit(0.9,
>> >>>>> "npc")))
>> >>>>>>   },
>> >>>>>>
>> >>>>>>
>> >>>>>
>> strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,
>> >>>>>> var.name="School"),
>> >>>>>>       xlab=deparse(substitute(x)),
>> >>>>>>       ylab=deparse(substitute(y)),
>> >>>>>>       main="Overlay of Profiles by Schools and Classes",
>> >>>>>> )
>> >>>>>>
>> >>>>>
>> >>>>
>> >>>>
>> >>>
>> >>
>> >
>> >       [[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.
>>
>> David Winsemius
>> Alameda, CA, USA
>>
>>
>

        [[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.

Reply via email to