r - ggplot2: Add a stacked bar showing the total distribution -
the following snippet creates stacked bars showing distribution of "clarity" "cut".
data(diamonds) qplot(cut, data=diamonds, geom="bar", fill=clarity, position="fill")
another plot shows total distribution of "clarity" entire dataset.
qplot(x=factor(""), data=diamonds, geom="bar", fill=clarity, position="fill")
is there way add second plot bar first plot, label "total"?
many approaches here's one:
diamonds2 <- diamonds diamonds2$cut <- "total" diamonds3 <- rbind(diamonds, diamonds2) qplot(cut, data=diamonds3, geom="bar", fill=clarity, position="fill")
Comments
Post a Comment