L'ultima immagine in this blog post.Come si crea un grafico a barre "annidato"?
Ho provato a cercare "grafico a barre annidato" e "grafico a barre gerarchico", ma potrebbero non essere la parola per esso.
L'ultima immagine in this blog post.Come si crea un grafico a barre "annidato"?
Ho provato a cercare "grafico a barre annidato" e "grafico a barre gerarchico", ma potrebbero non essere la parola per esso.
Usa ggplot
e creare strati separati:
library(ggplot2)
set.seed(1)
stupid <- data.frame(
group= LETTERS[1:5],
men = sample(1:10, 5),
women = sample(1:10, 5)
)
# Melt the data and calculate totals
mstupid <- melt(stupid, id.vars="group")
stupidTotal <- ddply(mstupid, .(group), summarize, value=sum(value))
ggplot() +
geom_bar(data=stupidTotal, aes(x=group, y=value), fill="grey50") +
geom_bar(data=mstupid, aes(x=group, y=value, fill=variable),
stat="identity", position="dodge") +
theme_bw()
Cercare 'barNest' nel pacchetto plotrix
Utilizzare questa:
ggplot() +
geom_bar(data=stupidTotal, aes(x=group, y=value, fill="grey50"), stat="identity") +
geom_bar(data=mstupid, aes(x=group, y=value, fill=variable),
stat="identity", position="dodge") +
theme_bw()