Legends in barplot not appearing properly

前端 未结 2 2007
别跟我提以往
别跟我提以往 2021-02-07 04:38
heights1=c(5,5,4.5,4,4,4,4.5,2,4,4)

opar <- par(lwd = 0.3)

barplot(heights1,xlim=c(0,3), ylim=c(0,5),  width=0.1, 
main=\"Langauges(Verbal & Non-verbal)\", 
nam         


        
2条回答
  •  太阳男子
    2021-02-07 05:04

    Change your legend line to

    legend("topright", c("reading/Writing", "Speaking"), col=c("darkblue","red"), lwd=10);
    

    The lwd argument says the legend should have lines of 10 pixel thickness of each of the corresponding colors. It's a good idea to use "topright" rather than "top" in your case so that the legend doesn't appear under the bars.

    enter image description here

提交回复
热议问题