是否有算法来创建像这样的分层条形图?
http://www.axiis.org/examples/HClusterColumnExample.html
相关问题: 2-layer barplot in R
答案 0 :(得分:1)
当然,有办法做到这一点。但那将是非常不标准的。但是,对barplot
的充分理解将为您带来很长的路要走:
# Create some toy data
set.seed(1)
n <- 100
df <- data.frame(F1 = sample(c("A", "B"), n, replace = TRUE),
F2 = sample(c("c", "d"), n, replace = TRUE))
tab <- t(table(df))
# Create plot
barplot(colSums(tab), width = 2, space = 0.5)
barplot(tab, beside = TRUE, add = TRUE, col = rainbow(2), axisnames = TRUE)
legend("top", col = rainbow(2), pch = 15, legend = rownames(tab))