r: barplot - 图例问题

r: barplot - legends issue

我怎样才能去掉图例中的方框,取而代之的是彩色线条?另外,如何将它们放在角落? 这是我正在使用的命令:

barplot(as.matrix(month_wise_data), main="Product sold per month",
    xlab="Products", col=brewer.pal(nrow(month_wise_data), "Paired"),legend = as.character(month_wise_data[,"MONTH"]), beside=TRUE,
    args.legend=list(x=100,y=10,bty = "n",pt.lwd=0.1, ncol = 3, cex=0.5,pch=1))

您必须像这样添加一个单独的 legend 调用:

barplot(VADeaths,beside =TRUE,col=1:5,ylim=c(0,100))
legend("topleft",legend=rownames(VADeaths),col=1:5,lty=1)