Color in the R language

Source: Internet
Author: User

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 ')

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.