Colors in R

To see the range of colors that are available in R, enter the following command:

colors()

You will see a set (a vector) of 657 colors arranged in alphabetical order. Let's see what we have at various indices in the vector of colors. Enter the following code. It contains square brackets, which allow us to identify and include elements of a vector that has the desired indices.

colors()[c(443,109,635, 548, 201)]

The output you will get is as follows:

1] "lightyellow" "darkslategray1" "turquoise" "purple1" "gray48"

Note

For more details on the available colors in R, refer to http://research.stowers-institute.org/efg/R/Color/Chart/.

However, you can control colors very easily using the codes given in the Hexadecimal Color Chart (reproduced from http://html-color-codes.com/).

These codes are given as combinations of numerals and alphabetic characters, always starting with the hash symbol (for example, #FF9966, which is a light orange color, or #669933, which is a light olive color). I recommend that you keep a copy of this chart and use the codes to create your own color schemes. You can download it from several sources simply by searching for Hexadecimal Color Chart. By referring to this chart, you always know the exact color or hue you are going to get.

Colors in R
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset