[R] legend
Jim Lemon
bitwrit at ozemail.com.au
Wed Jun 23 15:30:59 CEST 2004
Perez Martin, Agustin wrote:
> DeaR UseRs:
>
> I want to put a legend in my plot. In the first line of the legend I want
> to put a box filled but in the second one I would like to put a lty=2
>
> Of course it must appear with different colors.
>
I think I wrote this function about a year ago for someone, but I couldn't
find it anywhere. Here it is again.
Jim
-------------- next part --------------
add.legend.bars<-function(legend.info,whichbars,col,border="black") {
nelements<-length(legend.info$text$y)
left<-rep(legend.info$rect$left+
0.1*(legend.info$text$x[1]-legend.info$rect$left),nelements)
right<-rep(legend.info$rect$left+
0.8*(legend.info$text$x[1]-legend.info$rect$left),nelements)
top<-legend.info$text$y+(legend.info$text$y[1]-legend.info$text$y[2])/3
bottom<-top-(legend.info$text$y[1]-legend.info$text$y[2])/1.5
rect(left[whichbars],bottom[whichbars],
right[whichbars],top[whichbars],
col=col,border=border)
}
More information about the R-help
mailing list