Reputation: 561
I would like to create a horizontal proportional stacked bar "chart", using R.
My data is unidimensional. It represents failure rates in successive categories, and looks like this:
taskC=c(16, 10, 13, 5, 4, 5, 12)
labels=c("All correct", "1 fail", "2 fails", "3 fails", "4 fails", "5 fails", "All fail")
I would like to create something along the lines of the chart at the below URL, though using a different colour graident (topo is fine) and having it horizontal instead of vertical.
http://www.improving-visualisation.org/vis/id=70
I've looked through ggplot and VCD and can't find anything that solves this. A 3d graph would be ideal, though not critical. Although the data can be represented using a pie chart, these don't provide the linear sense of proportion I want, and also don't sufficiently capture the ordinal nature of the data.
Upvotes: 0
Views: 1997
Reputation: 51640
You can simply do:
barplot(as.matrix(taskC), horiz=TRUE, col=rainbow(7), xaxt="n")
axis(1, labels=labels, at=cumsum(taskC)-(taskC/2))
Upvotes: 1