如何创建堆叠的条形图

时间:2019-12-13 13:17:56

标签: r plotly r-plotly stacked-chart

我想从以下数据结构中以绘图方式创建交互式堆积条形图:

数据:

row_headers <- c("Item", month.abb)
row_01 <- c("Item01", floor(runif(12, min=0, max=100)))
row_02 <- c("Item02", floor(runif(12, min=0, max=100)))
row_03 <- c("Item03", floor(runif(12, min=0, max=100)))

dt <- rbind(row_01, row_02, row_03)
colnames(dt) <- row_headers
rownames(dt) <- seq(1,3,1)

dt

  Item     Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec 
1 "Item01" "79" "75" "84" "32" "79" "92" "94" "82" "68" "8"  "74" "55"
2 "Item02" "82" "61" "55" "76" "31" "38" "52" "7"  "85" "54" "62" "55"
3 "Item03" "53" "51" "82" "53" "98" "74" "79" "12" "17" "80" "95" "44"

图形:

X轴-个月

Y轴-所有商品的计数,但颜色不同的商品。

您碰巧知道我应该如何为它写纸条吗?

非常感谢您!

0 个答案:

没有答案