I'm trying to produce a barchart plot with groups, in which each group is placed in a particular time scale in x-axis. If I use barchart directly it does not take the time scale. I've tried with xyplot and adding a panel.barchart, I have the bars in the right place, but not the three groups I'm trying to produce. I've tried defining panel and panel.group, but can't get it to work
Drate is a numeric variable with three categories, perc a percentage of preys 
digested.

Script with barchart:
barchart(Perc~as.POSIXct(hora,format="%d-%m-%Y 
%H:%M"),digrate,groups=Drate,horizontal=F, key = leg,
  
scales=list(alternating=F,tck=c(1,0),x=list(at=1:10,labels=format(seq(r[1],r[2],"hours"),
    format="%H:%M"))),
            panel=function(x,y,...) {panel.fill(col="white")
            panel.barchart(x,y,col=c("white","grey","black"),...)}
            )

SCript with xyplot:
xyplot(Perc~as.POSIXct(hora,format="%d-%m-%Y %H:%M"),digrate,groups=digrate$Drate,key=leg,xlab="time of the day",

scales=list(alternating=F,tck=c(1,0),x=list(at=seq(r[1],r[2],by="hour"),labels=format(seq(r[1],r[2],"hours"),format="%H:%M"))),
            panel=function(x,y,groups,...) {
        panel.fill(col="white")
        panel.barchart(x,y,groups,horizontal=F,box.ratio=1000,stack=F,...)}
      )

Fran

______________________________________________
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