Color Selection [R plot] RGB color table

Source: Internet
Author: User

 

In R, plotting is done by specifying the col parameter of the plotting function, for example, par (BG = "cornsilk") # given the plotting background color x = rnorm (1000) y = cumsum (x) plot (Y, type = "L", Col = "red", xlab = "X Series ")

 

Col can assign Vectors

 

Method 1:

Use the color name, such as "Red", "green", and "Black "...

There are 657 colors available in R, which can be viewed and used through the colors () function.

 

 

CL = colors ()

 

X = runif (10000,-250,250)

Hist (x, breaks = seq (-250,250, 5), Col = Cl [])

Method 2: Use functions such as Rainbow (), heat. colors (), terrain. colors (), Topo. colors (), and CM. colors ().

 

 

 

 

 

 

Method 3: Use the function to set parameters in the color model.

(1) HCl () function

> ARGs (HCL)

Function (H = 0, c = 35, L = 85, Alpha, fixup = true)

H specifies the color, which is 0 ~ Integer between 360, 0 is red, 120 is green, 240 is blue, C is specified concentration, L is specified brightness, Alpha is specified transparency.

Example:

> X = runif (10000,-250,250)

> Hist (x, breaks = seq (-250,250, 5), Col = HCl ))

(2) HSV () function

> ARGs (HSV)

Function (H = 1, S = 1, V = 1, Gamma = 1, alpha)

Tone (H), saturation (s), brightness (V ).

Example:

> X = runif (10000,-250,250)

> Hist (x, breaks = seq (-250,250, 5), Col = HSV (SEQ (0.01,) # With seq sequence, the default saturation and brightness are 1

(3) Gray () or gray ()

 

> ARGs (Gray) function (level) Where: Level specifies the gray level, which is 0 ~ The number of one, 0 is black, and 1 is white. Example:> hist (x, breaks = seq (-250,250, 5), Col = gray (SEQ (0.01 )))

(4) RGB () function

This function specifies the color based on the three colors, red, green, and blue. RGB (r = 1, G = 0, B = 0) is red, RGB (r = 0, G = 1, B = 0) is green, RGB (r = 0, G = 0, B = 1) is blue. > ARGs (RGB) function (red, green, blue, Alpha, names = NULL, maxcolorvalue = 1)

When maxcolorvalue (max) is set to 255, RGB can be from 1 ~ 255 changes. It is consistent with the query value of the color table.

> Hist (x, breaks = seq (-250,250, 5), Col = RGB (r = 1, G = 0, B = 0 ))

Method 4: color gradient methods

(1) colorramp {grdevices} # colorramp function in the grdevices package

Example 1:

Ramp <-colorramp (C ("red", "White "))

RGB (ramp (SEQ (0, 1, length = 5), max = 255)

Example 2:

RGB. palette <-colorramppalette (C (RGB (35,179,225, max = 255), RGB (255, 24, 21, max = 247,236), RGB (255, 0, max = )), space = "RGB") # yellow, black, and blue

# RGB. palette <-colorramppalette (C (RGB (230,247,255, max = 255), RGB (35,179,225, max = 255), Space = "RGB") # blue gradient

 

RGB. palette (10)

 

Some color-related functions are attached:

 

> Rgb2hsv (255,255,255) # Convert RGB to HSV [, 1] H 0 s 0 V 1

 

 

>. Internal (rgb256 (0,255, 0,255, null) # Check the hexadecimal value of RGB [1] "# 00ff00ff"

 

 

 

You can find some nice colors by attaching the RGB color table:

 

RGB color table

Http://www.cnblogs.com/xianghang123/archive/2012/06/13/2547604.html

 

[Update]

Online color palette ~~ Easier Color Matching

Http://www.361dh.com/cx/yanse.htm

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.