Skip to content

help color coding map in R

2 messages · Felix Andrews, Anderson, Chris

#
Sorry, I was talking nonsense.

The actual problem was in your panel function, where you extract the
state boundaries, and then draw them using panel.polygon: the order of
states from map() is arbitrary, and does not correspond to the color
palette that you set up.

I suggest using mapplot(). This matches the region names you provide
to the names from the map.  However (as in your original case) you do
need to ensure that they match exactly, including case and sub-region
names...

i.e. you need to match up
    NatSTSummaryHigh.abi$JurisdtnStateName  with
    map("state", regions=NatSTSummaryHigh.abi$JurisdtnStateName)$names
(exactly).


nclr <- 4
plotclr <- brewer.pal(nclr,"PuRd")
class <- classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style="fisher" )

mapplot(tolower(JurisdtnStateName) ~ STMean, data = NatSTSummaryHigh.abi,
    map = us.map, breaks = class$brks, colramp = colorRampPalette(plotclr))


-Felix
On 18 May 2010 02:37, Anderson, Chris <chris.anderson at paradigmcorp.com> wrote:
-- 
Felix Andrews / ???
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
#
Thank you this was helpful

Chris Anderson
Data Analyst
Medical Affairs
wk: 925-677-4870
cell: 707-315-8486
Fax:925-677-4670


-----Original Message-----
From: foolish.android at gmail.com [mailto:foolish.android at gmail.com] On Behalf Of Felix Andrews
Sent: Monday, May 17, 2010 5:55 PM
To: Anderson, Chris
Cc: R-help Forum
Subject: Re: [R] help color coding map in R

Sorry, I was talking nonsense.

The actual problem was in your panel function, where you extract the
state boundaries, and then draw them using panel.polygon: the order of
states from map() is arbitrary, and does not correspond to the color
palette that you set up.

I suggest using mapplot(). This matches the region names you provide
to the names from the map.  However (as in your original case) you do
need to ensure that they match exactly, including case and sub-region
names...

i.e. you need to match up
    NatSTSummaryHigh.abi$JurisdtnStateName  with
    map("state", regions=NatSTSummaryHigh.abi$JurisdtnStateName)$names
(exactly).


nclr <- 4
plotclr <- brewer.pal(nclr,"PuRd")
class <- classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style="fisher" )

mapplot(tolower(JurisdtnStateName) ~ STMean, data = NatSTSummaryHigh.abi,
    map = us.map, breaks = class$brks, colramp = colorRampPalette(plotclr))


-Felix
On 18 May 2010 02:37, Anderson, Chris <chris.anderson at paradigmcorp.com> wrote:
-- 
Felix Andrews / ???
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C