在R中结合线条和条形图传说

时间:2012-05-15 08:53:42

标签: r plot legend

有办法吗?

我目前的代码:

barplot(to_plot_bar,col=cm.colors(6,alpha=1),width=0.75,space=0.2,names.arg=x)
lines(dat_dens,lty=1,col="black");
legend("topright",ltext,bty="n",fill=cm.colors(6),
lty = c(0,0,0,0,0,0,1), lwd = c(0,0,0,0,0,1));

产生这样的传奇。

enter image description here

1 个答案:

答案 0 :(得分:6)

试试这个

ltext1 <- c(ltext,"emp") # this is not necessary if you already added 
legend("topright",ltext1,bty="n",col=c(cm.colors(6),"black"),pch=c(rep(15,6),-1),
       lty = c(0,0,0,0,0,0,1));