I'm trying to turn this data
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
into an entropy chart , which looks something like this
My attempt only got me so far
ggplot(data, aes(x=as.factor(proportion), y=entropy)) +
geom_bar(stat="identity", aes(width=proportion))
Can it be done?
What about something like this
#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")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.