data <- structure(list(W= c(1L, 3L, 6L, 4L, 9L), X = c(2L, 5L,
4L, 5L, 12L), Y = c(4L, 4L, 6L, 6L, 16L), Z = c(3L, 5L,
6L, 7L, 6L)), .Names = c("W", "X", "Y", "Z"),
class = "data.frame", row.names = c(NA, -5L))
colours <- c("red", "orange", "blue", "yellow", "green")
barplot(as.matrix(data), main="My Barchart", ylab = "Numbers",
cex.lab = 1.5, cex.main = 1.4, beside=TRUE, col=colours).
这样做是可以的,但我需要分别对每个组进行降序排序,即显示相同的图表,但是按从高到低的顺序显示W
,…,Z
。例如:对于W
,绿色将从左侧开始,蓝色,黄色等等。对于x
,绿色将从左侧开始,橙色,黄色等等。