Dear R-users,

i want to plot gene regulation data in a lattice barchart. To illustrate 
the problem i encounter, the following code uses the "barley"dataset:

library(lattice)
barley[["SD"]] <- 5

PLOT <- barchart(data=barley, yield~variety|site, groups=year,origin=0, 
as.table=TRUE,

scales=list(x=list(relation="same",
rot=30),
y=list(alternating=3,tck=-1)),
col=c("grey","black"),
panel=function(...) {
panel.grid(h=-1, v=0,col="darkgrey");
panel.barchart(...,reference=FALSE)}
)
PLOT

#this works fine

#No, i tried to add error bars using the following code:

PLOT2 <- barchart(data=barley, yield~variety|site, groups=year,origin=0, 
as.table=TRUE,
scales=list(x=list(relation="same",
rot=30),
y=list(alternating=3,tck=-1)),
col=c("grey","black"),
sd=barley$SD,
prepanel=function(x,y,sd,subscripts,...){
ylim <- list(ylim=c(min(y-sd[subscripts],na.rm=TRUE),
max(y+sd[subscripts], na.rm=TRUE)))
},
panel=function(x,y,subscripts,sd,...){
panel.grid(h = -1, v = 0,col="darkgrey")
larrows(x0=x, y0=y, x1=x, y1=y-sd[subscripts],angle=90, code=2, 
length=0.075,
)
larrows(x0=x, y0=y, x1=x, y1=y+sd[subscripts],angle=90, code=2, 
length=0.075,
)
panel.barchart(x,y,subscripts=subscripts,reference=FALSE,...)
})
PLOT2

The problem is that the error bars are not attached correctly to the bars. 
I searched for solutions in the mailing list and found some postings and 
proposed solutions, but i was not able to solve the problem. Thanks for any 
hints to get the error bars correctly attached to the columns.

Greetings, Henning
    
-- 
GRATIS! Movie-FLAT mit über 300 Videos. 


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