R语言绘制树形图
数据格式:
> head(goodsstat)
goodsID count_goods count_goods_back pay_goods
451 PR000450 147 22 98399.32
714 PR000713 148 34 123259.05
756 PR000755 148 24 118296.08
922 PR000921 149 29 97571.72
67 PR000066 150 16 73516.01
531 PR000530 150 17 127541.42
count_goods_back_pay discount_goods
451 19705.18 51.78265
714 21223.53 47.71522
756 20813.87 58.46764
922 28801.92 64.28767
67 5389.35 38.95419
531 13512.09 51.30995
discount_goods_back meanpay_goods backpercent
451 55.50727 698.8432 0.1496599
714 28.99706 793.8603 0.2297297
756 96.87065 808.7788 0.1621622
922 44.22586 709.9643 0.1946309
67 24.95875 475.3335 0.1066667
531 35.52702 844.6318 0.1133333
运行绘图程序:
library(treemap)
goodsstat<-goodsstat[order(goodsstat$count_goods),]
treemap(goodsstat,index = c("goodsID"),vSize = "count_goods",
vColor = "backpercent",type="value",palette="RdYlGn",
title = "每个产品的销量和退货率比较",fontfamily.title = "STKaiti",
title.legend = "退款率",fontfamily.legend="STKaiti")
可得到: