I'm trying to produce a barplot with bar widths determined by an integer variable (sample size). Adding "width = variableName" doesn't seem to work. Is there an established way of doing this? Here's some dummy data and code. I want the bar widths to be a function of variable d in this example.
dat <- data.frame(a=c("A", "B", "C"), b=c(0.71, 0.94, 0.85), d=c(32, 99, 18))
ggplot(dat, aes(x=a, y=开发者_如何学运维b, fill=a)) +
geom_bar(colour="black", size=.3) +
theme_bw()
How about using width=
after rescaling your d
vector, say by a constant amount?
ggplot(dat, aes(x=a, y=b, width=d/100)) +
geom_bar(aes(fill=a), stat="identity", position="identity")
精彩评论