How to realize R preset color matching system and custom color swatch in r language
This article is about how to implement R preset color matching system and custom color swatches in r language. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The content mainly consists of two parts:
R preset color system swatches
R language custom color call
In fact, in the R language color system, there are two types of color systems, one is the preset color palette, through the color palette, you can get any number of color combinations.
There are five default palettes for the R language:
Rainbow
Heat.colors
Terrain.colors
Topo.colors
Cm.colors
These five color palettes are like a large dye vat, arranged with countless color combinations. Color selection is also very simple, that is, you can use the preset color disk name + color data:
Rainbow (10)
[1] "# FF0000FF"# FF9900FF"# CCFF00FF"# 33FF00FF"# 00FF66FF"# 00FFFFFF"
[7] "# 0066FFFF"# 3300FFFF"# CC00FFFF"# FF0099FF"
Since the above is a group of 10 colors obtained by name + quantity, we can also view the specific color effect through the show_col function in the scales package:
Library (scales)
Show_col (rainbow (10), labels=T) # labels controls whether color value information in HEX format is displayed.
Next, I use a layout matrix to display all five color plates:
Par (mfrow=c (1), mar=c (0.5), xaxs= "I", yaxs= "I")
N