R365: Day 9 – colors in R

R365: Day 9 – colors in R
While plotting out maps (see Day 8), I noticed that I could choose the color palette that the maps were displayed in. This got me thinking about how to choose or display different color groups. I remembered a presentation by a fellow grad student showing the various palettes that R had, but I could not remember how to access the proper code when trying to alter the map.
Here is the original map with no colors:
map(‘county’, ‘california’, fill = FALSE, col = palette())
and here is the altered map with a heat color for each of the 59 counties
map(“county”, “california”, fill = TRUE, col = heat.colors(59))
note that the heat colors are not designated by anything, theyre purely randomized in this example. Other color palettes exist, such as rainbow(), terrain.colors(), topo.colors(), and cm.colors(). Some color palettes, like gray(), hsv(), and rgb() take more getting used to, but can give more precise outputs for color scales.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s