我试图改变这些数据
data = data.frame(group = c("a", "b", "c", "d"),
proportion = c(0.101787806629625, 0.578844918169105, 0.11046225951544, 0.20890501568583),
entropy = c(0.521351652432232, 0.519605602533547, 0.443798118049615, 0.495838610457753 ))
group proportion entropy
a 0.1017878 0.5213517
b 0.5788449 0.5196056
c 0.1104623 0.4437981
d 0.2089050 0.4958386
进入熵图,看起来像这样
我的尝试只让我到目前为止
ggplot(data, aes(x=as.factor(proportion), y=entropy)) +
geom_bar(stat="identity", aes(width=proportion))
可以吗?
答案 0 :(得分:3)
这样的事情
#transform data
data<-data[order(data$entropy),]
data$cp<-cumsum(data$proportion)
#plot
ggplot(data, aes(xmin=cp-proportion, xmax=cp, ymin=0, ymax=entropy)) +
geom_rect(aes(fill=group)) + xlab("proportion") + ylab("entropy")