通过r中图例中的符号删除线条

时间:2012-09-19 13:46:17

标签: r plot legend

如何删除与r图例中的符号相交的线条?看了看传奇但似乎无法找到答案..

plot.new()

legend("top",ncol=1,c("Mound reef (M)","Spur and Groove (SG)",
    "Rubble Fields (RF)","Coral Walls (CW)","Mounds and rubble fields (MR)",
    "Mounds, Monostand walls and Rubble (MMR)"),pch=3:8, title="Reef Types", 
    cex=1, lwd=2)

enter image description here

2 个答案:

答案 0 :(得分:4)

只需添加lty=NULL

即可
plot.new()
legend("top",ncol=1,c("Mound reef (M)","Spur and Groove (SG)",
                      "Rubble Fields (RF)","Coral Walls (CW)",
                      "Mounds and rubble fields (MR)",
                      "Mounds, Monostand walls and Rubble (MMR)"),
       pch=3:8, title="Reef Types",cex=1,lwd=2, lty=NULL)

修改

正如Josh O'Brien所指出的,删除lwd=2就足够了,所以,你的代码应该是:

plot.new()
legend("top",ncol=1,c("Mound reef (M)","Spur and Groove (SG)",
                      "Rubble Fields (RF)","Coral Walls (CW)",
                      "Mounds and rubble fields (MR)",
                      "Mounds, Monostand walls and Rubble (MMR)"),
       pch=3:8, title="Reef Types",cex=1)

enter image description here

答案 1 :(得分:3)

您只是因为指定了lwd=2而获得了这些行,告诉您希望“{width} = 2”的legend()函数。如果您不想要行,只需删除lwd=参数。