Http://xccds1977.blogspot.com/2011/11/r_16.html
Statisticians often nag such a word, "a good picture is better than words." "Drawing is the strength of the R language. The basic drawing commands include a large number of parameter configurations, which can meet the needs of various publications, not to mention the existence of lattice and ggplot2, the two large lattice plot packages. Foreign media, including CNN, are using the powerful mapping capabilities of R to show the beauty of data. Excellent graphic expression can not be separated from the rich color collocation, let us get an initial look at the R drawing color settings.
Let's just grab a pie chart.
Pie (Rep (1,10))
I have to say that the default color is really weak, let us call the Rainbow function to add a bit of color, it feels much better
Mycolors=rainbow (10)
Pie (Rep (1,10), labels=mycolors,col=mycolors)
If you just want to see grayscale, that's fine.
Mycolors=gray (0:10/10)
Pie (Rep (1,10), labels=mycolors,col=mycolors)
In addition, the following functions can also generate a variety of colors you need heat.colors,terrain.colors (), Topo.colors,cm.colors,
If you need to use color accurately, it is recommended to use RGB, red green blue Three colors to define the color
Mycolors=rgb (red= (0:10)/10, green=0, blue=0)
Pie (Rep (1,10), labels=mycolors,col=mycolors)
On the side of the pie chart above is the name of the color, you can use the color wheel as a palette, and then the fancy color in other graphics, as in the following example
X=runif (5)
Names (x) =c (' A ', ' B ', ' C ', ' D ', ' E ')
Barplot (sort (x,decreasing=t), col= ' #4C0000 ', space=0.7,ylab= "value", main= ' Barplot Example ')