How to make an overlapping barplot?
问题 Making a barplot the 'standard' way dat <- read.table(text = "A B + 1 1 4 + 2 2 3 + 3 3 2 + 4 4 1", header = TRUE) barplot(as.matrix(dat)) gives a barplot like this: Instead, I would like to have the different segnments to overlap, like so How can I make such a plot in R? 回答1: There are two ways I have used: (counts <- with(diamonds, table(cut, clarity))) # clarity # cut I1 SI2 SI1 VS2 VS1 VVS2 VVS1 IF # Fair 210 466 408 261 170 69 17 9 # Good 96 1081 1560 978 648 286 186 71 # Very Good 84