[R] Equal confidence interval arrowhead lengths across multiple-paneled lattice plots with free y-scales
Bob Farmer
farmerb at gmail.com
Fri Nov 16 14:26:27 CET 2007
Yep, that did it, thanks.
--Bob
Deepayan Sarkar wrote:
> On Nov 15, 2007 8:08 PM, Bob Farmer <farmerb at gmail.com> wrote:
>> Hi.
>> I've got a lattice plot with multiple panels and two groups superimposed
>> on each panel. Each panel has an independently scaled y-axis (scales =
>> list(relation = "free")).
>>
>> I've successfully put up 95%CI error bars using panel.arrows (and some
>> help from the mailing list). My question is whether I can "unscale" the
>> arrowheads so that they appear to have the same length across all panels.
>> I recognize from the help-file that the "length" argument in
>> panel.arrows is in terms of grid units (which I assume are specific to
>> the particular panel). Can anybody think of a way to set the length so
>> that it appears uniform across all panels?
>
> The obvious approach would be to use a relative unit like "cm" or
> "inch" instead of an absolute one like "native". Does that not work?
>
> -Deepayan
>
>> Example code:
>>
>> summTable<-data.frame("X" = seq(1,12), "Y" =
>> c(1,8,3,6,6,5,7,3,8,1,10,-2),
>> "Location" = rep(c("Site1", "Site2"), times = c(6,6)),
>> "Species" = rep(c("A", "B"), 6)
>> )
>>
>> #change scale for Site 1
>> summTable[1:6,2]<-100*summTable[1:6,2]
>>
>> #arbitrary confidence intervals
>> summTable<-cbind(summTable, "ly" = (summTable$Y*(.98)),
>> "uy" = (summTable$Y*1.02)
>> )
>>
>> #panel plotting
>> panel.func<-function(x,y,ly,uy,subscripts,...){
>> ly<-as.numeric(ly)[subscripts]
>> uy<-as.numeric(uy)[subscripts]
>> panel.arrows(x,ly,x,uy,
>> unit = "native",
>> angle = 90,
>> length = .25,
>> code = 3,
>> )
>> panel.xyplot(x,y,...)
>> }
>> xyplot(Y ~ X | Location, groups = Species,
>> type = "l",
>> data = summTable,
>> scales = list(relation = "free"),
>> ly = summTable$ly, uy = summTable$uy,
>> auto.key = T,
>> panel = panel.superpose,
>> panel.groups = panel.func
>> )
>>
>> Thank you.
>>
>> --Bob Farmer
>> (using R 2.6.0 and lattice 0.16-5)
>>
>> ______________________________________________
>> R-help at 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.
>>
>
More information about the R-help
mailing list