您好我正在尝试创建一个旁边的条形图,但我的条形图不在正确的空格中似乎重叠。
barplot(counts,
main ="2011 vs 2016 Men Volunteering",
ylim=c(0,320000),
xlab="Age (years)",
ylab = "Frequancy",
names.arg = c("15-19", "20-24", "25-34", "35-44", "45-54", "55-64", "65-74", "75-84", "84 and over"),
col=c("red","green"),
beside=TRUE)
legend("topright",
legend = c("2011", "2016"),
fill = c("red", "green"))
输出:
实际上我希望它看起来像这样:
我尝试过使用ncol = 2,但我无法使用它,我该如何实现呢?
像这样,
barplot(counts,
main ="2011 vs 2016 Men Volunteering",
ylim=c(0,320000),
xlab="Age (years)",
ylab = "Frequancy",
names.arg = c("15-19", "20-24", "25-34", "35-44", "45-54", "55-64", "65-74", "75-84", "84 and over"),
ncol = 2,
col=c("red","green"),
beside=TRUE)
legend("topright",
legend = c("2011", "2016"),
fill = c("red", "green"))
还是这个?
counts <- as.matrix(ELEVENMenVolunteerAge, SIXTEENMenVolunteerAge, ncol = 2)
所有帮助表示非常感谢。