Mapping color

Color chart with direct experience and decided to give the reader the impression charts, graphs beautiful natural article will give considerably. Therefore, learn to customize the color chart is very important.

3 color combinations (color obtain a set of color values) of the method.

The essence of color is to get a group with a very "harmonious" color. R in common with a color representation of hexadecimal color code, English code, the RGB color values ​​in three ways. Common R color matching bag as RColorBrewer, ggsci, ggtech provide ready-made color matching program can be directly used. Below RColorBrewer example:

library(RColorBrewer)

display.brewer.all(type = "seq")

display.brewer.all(type = "qual")

Here only two types of color output, as in FIG.

 

 colors1<-brewer.pal(9,"RdPu")

colors1

"#FFF7F3" "#FDE0DD" "#FCC5C0" "#FA9FB5""#F768A1" "#DD3497" "#AE017E" "#7A0177""#49006A"

colors1<-brewer.pal(9,"Dark2")

"#1B9E77" "#D95F02" "#7570B3" "#E7298A" "#66A61E" "#E6AB02" "#A6761D"
 "#666666"

Another color Artifact: colortools

https://rpubs.com/gaston/colortools

Instructions:

安装 install.packages("colortools")

  library(colortools)

#色轮的生成
wheel("darkblue", num = 12)
barplot(1:12,names.arg=my1,col=my1,las=2)

#单色搭配(Monochromatic )色系的生成
sequential("red")
#
类比色搭配(Analogous )与补色/对比色搭配(Complement )色轮可以方便地生成相邻、对比等色系

analogous("darkblue")
#Complementary color scheme
complementary("steelblue")

# define some colors some_colors = setColors("#3D6DCC", 15) # pizza plot pizza(some_colors) # analagous scheme for color "#3D6DCC" analogous("#3D6DCC") # complementary scheme for color "#3D6DCC" complementary("#3D6DCC") # split complementary scheme for color "#3D6DCC" splitComp("#3D6DCC") # triadic scheme for color "#3D6DCC" triadic("#3D6DCC") # tetradic scheme for color "#3D6DCC" tetradic("#3D6DCC") # square scheme for color "#3D6DCC" square("#3D6DCC") # sequential colors for "#3D6DCC" sequential("#3D6DCC")

 pals()

pals("cheer")

# color names of palette 'cheer'pizza(pals("cheer")

pizza(terrain.colors(12), bg="white")

p<-setColors(3, num=18)

hist(rnorm(100),breaks=10,col=p)

barplot(1:5,col=pals("cheer"))

#箱图的绘制

boxplot(len~dose*supp,data=ToothGrowth,col=pals("cheer"),xlab="group",ylab="len")

绘制聚类图

install.packages("pheatmap")

install.packages("cluster")

install.packages("ape")

library(pheatmap)

library(cluster)

library(ape)

my2<-setColors("blue",num=12) 

my3<-pals("drift")

pheatmap(scale(mtcars),col=my2)

#配色可以让我们生成热图中的数据更加清晰、直观

pheatmap(scale(mtcars),col=sequential("blue",10))

pheatmap(scale(mtcars),col=my3,cutree_rows = 3)

plot(as.phylo(hclust(dist(scale(mtcars)))),tip.col=my1)

set.seed(100)

m.c<-kmeans(scale(mtcars),centers=3)

pairs(mtcars[,1:5],pch=21,bg=pals("mystery")[m.c$cluster])

#散点图与k-mean聚类联合分析中,不同互补色系可以更加和谐的表征不同组别的点的分布

综上,通过改颜色工具包,可以便捷的得到我们想要的配色乃至独特的色系。

此外,还可以用windows的取色器,mspaint

在线取色网站

http://tool.oschina.net/commons?type=3

 

Guess you like

Origin www.cnblogs.com/marszhw/p/11104885.html