0

我很抱歉这个非信息性的标题。

> y=read.csv(textConnection(scan("",sep="\n",what="raw")))
"","org","art","type","length"
"191","gk","Finish","short",4
"147","ik","Attending","short",7
"175","gl","Finish","long",11
"192","il","Attending","long",95
"144","gm","Finish","between",5
"161","im","Attending","between",15
"164","tu","Something","young",8
"190","tv","Something","old",4

> decompress=function(x)x[rep(1:nrow(x),x$length),-ncol(x)]
> exstatus=decompress(y)

然后情节

ggplot(exstatus, aes(x=type, fill=art))+
geom_bar(aes(y=..count../sum(..count..)),position="dodge")

问题是最右边的两个条(“年轻”、“老”)太厚了——“某物”占据了整个宽度——这不是我想要的。

替代文字 http://www.imagechicken.com/uploads/1272295176088679800.png

很抱歉,我无法更好地解释它。

4

1 回答 1

3

使用 facet_grid 代替 position="dodge"

  ggplot(exstatus, aes(x=art, fill=art))+
  geom_bar(aes(y=..count../sum(..count..))) + 
  facet_grid(~type,scales="free",space="free")

替代文字 http://www.imagechicken.com/uploads/1272294360054813000.png

于 2010-04-26T14:04:00.710 回答