5
這裏是我的簡單數據:當geom_text不合適時,如何在ggplot中放置百分比標籤?
company <-c(rep(c(rep("company1",4),rep("company2",4),rep("company3",4)),3))
product<-c(rep(c(rep(c("product1","product2","product3","product4"),3)),3))
week<-c(c(rep("w1",12),rep("w2",12),rep("w3",12)))
mydata<-data.frame(company=company,product=product,week=week)
mydata$rank<-c(rep(c(1,3,2,3,2,1,3,2,3,2,1,1),3))
mydata=mydata[mydata$company=="company1",]
而且,R碼我用:
ggplot(mydata,aes(x = week,fill = as.factor(rank))) +
geom_bar(position = "fill")+
scale_y_continuous(labels = percent_format())
在酒吧裏的情節,我想通過標籤周百分比,按職級。 問題是數據沒有排名的百分比。這個數據的結構不適合有一個。 (當然,原始數據比例子有更多的觀察)
有沒有人可以教我如何在這個圖表中標記百分比?