Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing lines through symbols in legend in r

Tags:

plot

r

legend

How can I remove the lines that intersect the symbols in an r legend? Have looked through ?legend but can't seem to find an answer..

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

like image 829
Elizabeth Avatar asked Sep 19 '12 13:09

Elizabeth


2 Answers

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

EDIT

Deleting lwd=2 should suffice as pointed out by Josh O'Brien, so, your code should be:

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

like image 105
Jilber Urbina Avatar answered Nov 09 '22 08:11

Jilber Urbina


You are only getting those lines because you specified lwd=2, which tells the legend() function that you want "line width=2". If you don't want lines, just drop the lwd= argument.

like image 3
Josh O'Brien Avatar answered Nov 09 '22 06:11

Josh O'Brien