Hi list,

I have been trying to create a legend for a plot that includes polygons,
lines, and points.  I've included an example below.
I have two problems with this legend.
1. I can't seem to change the colour of the box that represents the polygon
in the legend.
2. The boxes and points in the legend don't align vertically.

If you could suggest solutions it would be greatly appreciated.

x<-c(1,4,4,1)
y<-c(4,4,1,1)
a<-c(5,3)
b<-c(4,5)
e<-c(1,1.1,1.4,1.6)
f<-c(4.2,4.5,4.6,5)

plot(x,y,ylim=c(0,6),xlim=c(0,6),col="green")
polygon(x,y,density=10,col="green")
points(a,b)
points(e,f,pch=16,col="yellow")
lines(a,b,lwd=2,col="red")

legend('bottomright',legend=c("polygon","lines","points"),
pch=c(NA,NA,16),
lty=c(-1,1,-1),
lwd=c(NA,2,NA),
density=c(10,0,0),
border=c(1,0,0),
col=c("green","red","yellow"))

Thanks in advance
Mark Wallace
PhD student
University of Western Australia

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to