tags:

views:

122

answers:

5

Does R have color palettes?

In other words, I am looking for an array of 6 or so color names that go well together in a graph or plot; maybe there are some predefined schemes like that?

+4  A: 

Look at the RColorBrewer package. The colors are not named, but I think that they are close to what you are looking for.

deinst
+6  A: 

RColorBrewer, as mentioned by deinst, is very useful -- even though it was designed for maps rather than line charts.

A number of other packages offer help with palettes:

as can be seen from a quick query on 'palette' at rseek.org.

Dirk Eddelbuettel
+2  A: 

The easiest way to generate a palette is using generic functions from the basic grDevices package:

rainbow()
topo.colors()
terrain.colors()
heat.colors()

These are useful if the desired number of colors doesn't exceed 7-8. The only necessary argument is the number of colors in palette.

There is also gray() function which can be used to generate various schades of gray.

donshikin
I'm accepting this because it's standard R, without the need for additional packages. (See also Marek's mention of `palette`). The other answers about RColorBrewer were also extremely helpful!
+2  A: 

Visit this page before using RColorBrewer. Select the number of your data classes in the top and then define the nature of your data. You may also find this page useful.

gd047
+2  A: 

No one mention this but look at palette function (?palette) which define default pallet.

palette()[1:6] gives you first six default colours.

Marek