我有一个图例,但它会覆盖条形图中的一列。
BOD<-matrix(c(2846,2397,4408,3563,2001,1713,4137,3197,136,107,307,203),
nrow = 3, byrow = T)
colnames(BOD)<-c("BOD","BOD lọc","COD","COD lọc")
DT <- barplot(BOD,
main="Do Thi BOD",
legend=c("<5 Nam","5-10 Nam",">10 Nam"),
beside = T)
答案 0 :(得分:-1)
您可以使用legend("topleft", …)
(假设您的问题是重新定位图例)。
BOD<-matrix(c(2846,2397,4408,3563,2001,1713,4137,3197,136,107,307,203),
nrow = 3, byrow = T)
colnames(BOD)<-c("BOD","BOD lọc","COD","COD lọc")
DT <- barplot(BOD,main="Do Thi BOD",beside = T)
legend("topleft",legend=c("<5 Nam","5-10 Nam",">10 Nam"))
这是我的情节:
修改强>
更为独特的方法是在args.legend
内使用legend.text
和barplot
,例如
DT <- barplot(BOD,
main="Do Thi BOD",
legend.text = c("<5 Nam","5-10 Nam",">10 Nam"),
args.legend = list(x = "topleft"),
beside = T)