使用ggplot2很容易做,将数据整理为csv文件:
| week | project | number |
| first | p1 | 48 |
| second | p1 | 25 |
| third | p1 | 34 |
| fourth | p1 | 55 |
| first | p2 | 82 |
| second | p2 | 131 |
| third | p2 | 134 |
| fourth | p2 | 180 |
| first | p3 | 4 |
| second | p3 | 1 |
| third | p3 | 0 |
| fourth | p3 | 0 |
| first | P4 | 1 |
| second | P4 | 11 |
| third | P4 | 112 |
| fourth | P4 | 53 |
library(ggplot2)
data<- read.csv("data.csv",head=T)
p<- ggplot(data,aes(x=week,y=number,fill=project))
p+geom_bar(stat="identity",position = "stack") #position可设置为stack,dodge,fill等,分别为堆叠、并列和填充。
不知道是不是楼主要的样子