# [R] Plotting colors on a world map

dxc13 dxc13 at health.state.ny.us
Tue May 12 05:02:42 CEST 2009

```So, this would allow me to assign a color to each of the 2592 rectangular
grid cells on a map of the world?  I guess I am having trouble finding a
suitable method of doing this.  Also, to be able to distinguish country
boundaries from the grid lines (which are both black color), could the grid
lines be transparent so that all we see is the map of the world in various
colors?
I was thinking that <10 degrees would be light blue, 10-30 degrees would be
blue, 31-40 be green, 41-50 be yellow, 51-60 be dark yellow, 61-70 be
orange, 71-80 be red, 81-90 be dark red.

Any help is appreciated in getting this task accomplished.  Thanks

Duncan Murdoch-2 wrote:
>
> On 5/11/2009 10:32 AM, dxc13 wrote:
>> Hi useR's
>>
>> I have created a simple map of the world using the following code:
>> m <- map(xlim=c(-180,180), ylim=c(-90,90))
>> map.axes()
>>
>> I then create a grid of dimension 36x72 using the code:
>> map.grid(m, nx=72, ny=36, labels=FALSE, col="black")
>>
>> This gives 2592 grid cells.  In a separate data set of dimension 36x72, I
>> have 2592 temperature values (some missing values are present) ranging
>> from
>> -20 degrees F to 90 degrees F.
>>
>> My question is, how can I create a reasonable color scheme (low
>> temperatures
>> in light blue to higher temperatures in dark red) and plot the
>> temperature
>> colors in their respective grid cells on the map?
>>
>> Take this data matrix as some example data:
>> T <- sample(-10:90, 2592, replace=TRUE)
>> mat <- matrix(T, nrow=36, ncol=72)
>
>
> The colorspace package can make nice color sequences for this sort of
> thing, and image() can add them to a plot.  In colorspace, look at the
> examples for diverge_hcl.
>
> Duncan Murdoch
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

--
View this message in context: http://www.nabble.com/Plotting-colors-on-a-world-map-tp23484524p23495370.html
Sent from the R help mailing list archive at Nabble.com.

```