[R] Different type of legend?

Kevin Burton rkevinburton at charter.net
Tue Jan 31 18:31:58 CET 2012


There must be a trick because I am not seeing a legend:

> library(maps)
> library(plotrix)
> colors <- grey(0:10/10)
> mo <- map('county', projection='polyconic')
> leg.txt <- c("-1", "0", "1")
> color.legend(mo$range[1]-1,mo$range[2]-3,mo$range[2]+1,mo$range[2]-2,
+                           leg.txt[c(1,length(leg.txt)/2,length(leg.txt))],
+                           colors[-1],
+                           align='rb',
+
col=colors[-1][c(1,length(colors[-1])/2,length(colors[-1]))])

-----Original Message-----
From: Jim Lemon [mailto:jim at bitwrit.com.au] 
Sent: Tuesday, January 31, 2012 3:37 AM
To: rkevinburton at charter.net
Cc: r-help at r-project.org
Subject: Re: [R] Different type of legend?

On 01/31/2012 08:54 AM, rkevinburton at charter.net wrote:
> Sorry. I am not sure how to post a link. Basically the legend looks like:
>
> * * * * * * * * * * *
> -4 -3 -2 -1 0 1 2 3 4
>
> Where ' * ' are colored boxes that are right next to each other. Kind 
> of like a gradient.
>
Hi Kevin,
The color.legend function (plotrix) might do what you want.

Jim



More information about the R-help mailing list