2017-04-24 32 views
0

Product Sales per month**strong text**R:barplot - 传说中的问题

我怎样才能在传说摆脱箱,并得到代替彩色线条?另外,我怎么把它们放在一个角落? 这是我使用的命令:

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)) 

回答

4

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

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

enter image description here