Getting a stacked area plot in R

前端 未结 3 1435
你的背包
你的背包 2020-11-28 10:01

This question is a continuation of the previous question I asked.

Now I have a case where there is also a category column with Prop. So, the dataset becomes like

3条回答
  •  孤街浪徒
    2020-11-28 10:43

    You can use stackpoly from the plotrix package:

    library(plotrix)
    #create proportions table
    pdat <- prop.table(xtabs(Prop2~Hour+Category,Dat),margin=1)
    #draw chart
    stackpoly(pdat,stack=T,xaxlab=rownames(pdat))
    #add legend
    legend(1,colnames(pdat),bg="#ffffff55",fill=rainbow(dim(pdat)[2]))
    

提交回复
热议问题