In Lattice the scales
arguments control the axis; Probably something along the lines of this untested code:
..., scales=list(y=list(at=seq.POSIXt(0, 700, length= 6),
labels=format(seq.POSIXt(0, 700, length= 6), "%H:%M:%S:)
), ...
To get this in tested form I needed to convert the seconds to POSIXt format:
mydata$val1time <- as.POSIXct(mydata$val1, origin="1970-01-01")
barchart(val1time ~ val2, groups=group, mydata, horizontal=FALSE,
scales=list( y=list(
at=seq.POSIXt(from=as.POSIXct(0, origin="1970-01-01"),
to=as.POSIXct(700, origin="1970-01-01"), length= 12),
labels=format( seq.POSIXt(from=as.POSIXct(0, origin="1970-01-01"),
to=as.POSIXct(720, origin="1970-01-01"), length= 12), "%H:%M:%S")
) ),
auto.key=list(
columns=1,
space="right",
text=c("Pilot 1","Pilot 2")
),
main="Title", xlab="Tasks", ylab="Duration"
)
And if you needed it to go from 0 upwards you would need to add:
..., ylim=range( as.numeric( seq.POSIXt(from=as.POSIXct(0, origin="1970-01-01"),
to=as.POSIXct(700, origin="1970-01-01"),
length= 12))) ,
For the purposes of showing that an entire set of commands give that result (with the addition of the 'ylim' argument, I am pasting the code I used with the dataframe name dat
:
dat <- read.table(text="group,val2,val1
pilot01,t1,429.226015
pilot01,t3,693.795607
pilot02,t1,262.798468
pilot02,t3,325.854107", header=TRUE, sep=",")
dat$val1time <- as.POSIXct(dat$val1, origin="1970-01-01")
barchart(val1time ~ val2, groups=group, dat, horizontal=FALSE,
scales=list( y=list( at=seq.POSIXt(from=as.POSIXct(0, origin="1970-01-01"), to=as.POSIXct(700, origin="1970-01-01"), length= 12),
labels=format( seq.POSIXt(from=as.POSIXct(0, origin="1970-01-01"), to=as.POSIXct(720, origin="1970-01-01"), length= 12), "%H:%M:%S")
) ),
auto.key=list(
columns=1,
space="right",
text=c("Pilot 1","Pilot 2")
),
main="Title", xlab="Tasks", ylab="Duration"
, ylim=range( as.numeric( seq.POSIXt(from=as.POSIXct(0, origin="1970-01-01"),
to=as.POSIXct(700, origin="1970-01-01"),
length= 12))))