我有一个两边都有正值的条形图。当我更改条的宽度时,它们之间的空间变得很大并且看起来不太好。我试图用 来操纵它position = position_dodge
,但它不起作用。我怎样才能减少酒吧之间的空间?
这是包含我的数据的代码(最初发布在这里Stacked barplot cross the x-axis):
Year <- factor(c("2003-2009","2003-2009","2003-2009","2003-2009","2003-2009","2009-2012",
"2009-2012","2009-2012","2009-2012","2009-2012"))
Q <- c(.05,.25,.5,.75,.95)
Score <- c(6,6,4,3,1,23,20,19,24,32)
df <- data.frame(Year, Q, Score)
df <- transform(df, Score=ifelse(as.character(Year) %in% c("2003-2009"), -Score, Score))
df.split <- split(df, df$Score < 0)
ggplot() +
geom_bar(data=df.split[[1]],aes(x=Q, y=Score, fill=Year), stat="identity",width = 0.09)+
geom_bar(data=df.split[[2]],aes(x=Q, y=Score, fill=Year), stat="identity",width = 0.09)+
geom_hline(yintercept=0) +
coord_flip()+
scale_y_continuous(labels=abs,limits=c(-40,40))+
theme_bw()+
scale_x_continuous(breaks=c(.05,.25,.5,.75,.95))