##############颜色
1.固有颜色:生成R语言中657种颜色名称及对应的颜色,并存于PDF.(附件是生存的PDF)
pdf("D:/colors-bar.pdf",height=120)
par(mar=c(0,10,3,0)+0.1,yaxs="i")
barplot(rep(1,length(colors())),col=rev(colors()),
+ names.arg=rev(colors()),horiz=TRUE,las=1,
+ xaxt="n",main=expression("Bars of colors in"~italic(colors())))
dev.off()
2.彩虹色
barplot(rep(1,41),col=c(rainbow(n=6,start=0,end=1/6),"white",rainbow(n=6,start=1/6,end=2/6),"white",rainbow(n=6,start=2/6,end=3/6),"white",rainbow(n=6,start=3/6,end=4/6),"white",rainbow(n=6,start=4/6,end=5/6),"white",rainbow(n=6,start=5/6,end=1)))
x.text<-c("赤色","黄色","绿色","青色","蓝色","紫色")
axis(side=1,at=seq(from=3,length.out=6,by=8.5),labels=x.text,cex=0.75)
3.四种主题配色函数(颜色渐变)(注:6为数目)
> barplot(rep(1,6),col=heat.colors(6))
> barplot(rep(1,6),col=terrain.colors(6))
> barplot(rep(1,6),col=topo.colors(6))
> barplot(rep(1,6),col=cm.colors(6))
4.RColorBrewer颜色扩展包
library(RColorBrewer)
4.1连续型
display.brewer.all(type="seq")
取YlOrRd中3-8种颜色
barplot(rep(1,6),col=brewer.pal(9,"YlOrRd")[3:8])
4.2极端型
display.brewer.all(type="div")
barplot(rep(1,6),col=brewer.pal(11,"BrBG")[3:8])
4.3离散型
display.brewer.all(type="qual")
barplot(rep(1,6),col=brewer.pal(12,"Paired")[3:8])
########################
1.字体
plot(c(0:5),col="white")
text(2,4,labels="font=1:正常字体(默认)",font=1)
text(3,3,labels="font=2:粗体字体",font=2)
text(4,2,labels="font=3:斜体字体",font=3)
text(5,1,labels="font=4:粗斜体字体",font=4)
2.大小
plot(c(0:6),col="white",xlim=c(1,8))
text(2,5,labels="cex0.5:放大0.5倍",cex=0.5)
3.点元素相关参数设置(shift+enter 换行)
3.1点样式和颜色
for(i in c(0:25)){}
此外,pch的取值还可以为:"* . o O 0 + - | "
points(6,5,pah="*",cex=2);text=(6.2,5.2,labels=paste("pch=\"*\""))
3.2大小
cex
4.线元素相关参数设置