Skip to content
Back to formatted view

Raw Message

Message-ID: <4E969F34.2040504@bitwrit.com.au>
Date: 2011-10-13T08:20:04Z
From: Jim Lemon
Subject: US States percentage change plot
In-Reply-To: <CAKa5rJBy1zRyZGcADe0eGUezdToVc230qNGJKB=w7UgLbqdXNw@mail.gmail.com>

On 10/13/2011 11:45 AM, Michael Charles Bailey I wrote:
> Hi, I would like to make a plot of the US states (or lower 48) that are
> colored based upon a percentage change column. Ideally, it would gradually
> be more blue the larger the positive change, and more red the more negative
> is the change.
>
> The data I have looks like:
>
>         State Percent.Change
> 1    Alabama    0.004040547
> 2     Alaska   -0.000202211
> 3    Arizona   -0.002524567
> 4   Arkansas   -0.008525333
> 5 California    0.001828754
> 6   Colorado    0.011116150
>
> I have read help for the maps library and similar plots online but can't
> grasp how to map the percentage.change column to the map. thank in advance,
>
Hi Michael,
I do a similar thing like this:

SEIFAcol<-color.scale(AU_SEIFA$SEIFA1dec[1:199],
  c(1,0.9,0.8,0.8),c(0.8,0.9,0.9,0.8),c(0.8,0.8,0.9,1),xrange=c(1,10))
...
plot(NSWmap,xlim=c(140,max(cdrt09$GeocodeX,na.rm=TRUE)),
  col=SEIFAcol)
SEIFAlegendcol<-color.scale(1:10,
  c(1,0.9,0.8,0.8),c(0.8,0.9,0.9,0.8),c(0.8,0.8,0.9,1))
color.legend(151.8,-37.5,152.3,-34.5,as.character(1:10),SEIFAlegendcol,
  align="rb",gradient="y")

In this case, Statistical Local Areas are being colored on the Index of 
Relative Social Disadvantage. The call to color.scale calculates a color 
for each of the 199 SLAs based on their IRSD score. If you want to 
define different color scales for positive and negative values, see the 
help page for color.scale (plotrix).

Jim