Re: [R] adding a legend to the plot (but outside of it)

2010-10-05 Thread Dimitri Liakhovitski
Thanks a lot, Thomas. May I ask 2 questions: 1. Is there a way to fill the legend rectangles with color (currently, they just contain a colored cross)? 2. Currently, my graph grabs the colors automatically (as I loop through var, it grabs col=all.colors[which(names(my.data) %in% var)]. I am

Re: [R] adding a legend to the plot (but outside of it)

2010-10-05 Thread Thomas Stewart
Dimitri- Regarding question 1, it is the pch argument that controls the legend symbol. In my configuration, pch=15 gives a colored, filled-in box. To see the possible pch symbols, run the following code: plot(0,0,xlim=c(0,9), ylim=c(0,9),type=n, axes=F,xlab=,ylab=) for(i in 0:9){ for(j in

Re: [R] adding a legend to the plot (but outside of it)

2010-10-05 Thread Dimitri Liakhovitski
THanks a lot, Thomas - I am 100% clear on the legend symbol now, very helpful. With legend colors - I just tried to have more colors in all.colors than there are variables to plot on the graph. Did it on purpose - so that there are always more colors to pick from. But if I do names(my.data) -

Re: [R] adding a legend to the plot (but outside of it)

2010-10-04 Thread Thomas Stewart
Right before the plot statement add: par(mar=c(5,4,4,6),xpd=F) then at the end add legend(par()$usr[2], mean(par()$usr[3:4]), c(Blue,Yellow,Green,Orange), xpd=T, bty=n, pch=15, col=c(Blue,Yellow,Green,Orange)) On Mon, Oct 4, 2010 at 5:16 PM, Dimitri Liakhovitski