你能帮我使用 ggplot2 包和mat
矩阵中的数据创建以下条形图吗?
mat <- matrix(c(70.93,78.58,78.72,69.24,62.53,43.85,83.49,70.00,78.30,78.11,71.16,63.82,47.37,89.87),ncol=2)
colnames(mat) <- c("Crude","Standardized")
rownames(mat) <- 2006:2012
library(gplots)
library(RColorBrewer)
my_palette <- palette(brewer.pal(7,"Set1"))
barplot2(mat,
main="Crude and Standardized Rates",
xlab="Type", ylab="Rate", xlim=c(0,20), ylim=c(40,100),
col=my_palette, beside=TRUE, plot.grid = TRUE, xpd=FALSE)
legend(locator(1), rownames(mat), title ="Year",fill=my_palette)