So I am trying to make a stacked bar graph with bar width mapped to a variable; but I want the spacing between my bars to be constant.
Does anyone know how to make t
Attempt # 2.
I'm tricking ggplot2 into writing a continuous scale as categorical.
# The numbers for tmp I calculated by hand. Not sure how to program
# this part but the math is
# last + half(previous_width) + half(current_width)
# Change the 1st number in cumsum to adjust the between category width
tmp <- c(2.91,7.02,14.715,27.75,38.22,46.47,57.845,77.19,101.235) + cumsum(rep(5,9))
dd$x.pos1 <- rep(tmp,each=5)
ggplot(dd,aes(x=x.pos1,y=value.y,fill=Date)) +
geom_bar(aes(width=value.x),stat="identity",position="stack") +
scale_x_continuous(breaks=tmp,labels=levels(dd$variable)) +
coord_flip()
For good measure you're probably going to want to adjust the text size. That's done with ... + opts(axis.text.y=theme_text(size=12))