如何更改以下条形图,以便:
1) 条之间没有空格。2)堆积条的颜色应该看起来,如果较高的被较小的填充。
tim.seq<-seq(as.POSIXlt("2013-07-01 00:00:00",origin = "1960-01-01",tz="GMT"),
as.POSIXlt("2013-07-8 00:00:00",origin = "1960-01-01",tz="GMT"),by="1 day")
library(ggplot2)
times<-rep(tim.seq,2)
key<-rep(LETTERS[1:2],each=length(times)/2)
times<-c(times,times)
key<-c(key,key)
ref<-rep(LETTERS[1:2],each=length(times)/2)
value<-to<-sample(1:20,length(times),T)
df<-data.frame(times=times,key=key,ref=ref,value=value)
p<-ggplot(df, aes(x=times))
p<-p + geom_bar(subset = .(ref =="A"), aes(y = value, fill = key), stat = "identity")
p<-p + geom_bar(subset = .(ref =="B"), aes(y = -value, fill = key), stat = "identity")
p<-p + geom_hline(yintercept = 0, colour = "grey90")
p