Skip to content
Prev 12557 / 398502 Next

pch with plot and legend

John Verzani <verzani at math.csi.cuny.edu> writes:
The legend() function doesn't care or know about the points you
plotted, so it expects pch to be a vector as long as the list of
legends. 

pch=seq(along=levels(supp)) looks about right. Or just pch=1:2

Alternately, think ahead:

sym <- c(1,2) # this could be changed to get a different set of symbols
plot(len ~ dose, pch=sym[supp])
legend(locator(1), pch=sym, legend=levels(supp))