5

如何删除与 r 图例中的符号相交的线?看过 ?legend 但似乎找不到答案..

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)

在此处输入图像描述

4

2 回答 2

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)

编辑

lwd=2正如 Josh O'Brien 指出的那样,删除就足够了,因此,您的代码应该是:

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)

在此处输入图像描述

于 2012-09-19T13:48:34.717 回答
3

您只得到这些行是因为您指定了lwd=2,它告诉legend()函数您想要“线宽 = 2”。如果您不想要线条,只需删除lwd=参数。

于 2012-09-19T13:51:55.273 回答