R IN ACTION SELF-TUTORIAL-73 作图所

2021-11-25  本文已影响0人  RashidinAbdu
colwritten<-c("#F3CECE","#F78181","#FF0000","#8A0808","#3B0B0B",
       "#F5BCA9","#F7BE81","#FF8000","#B45F04","#8A4B08",
       "#F2F5A9","#FFFF00","#AEB404","#868A08","#BEF781",
       "#80FF00","#5FB404","#58FAAC","#01DFA5","#00FFFF",
       "#04B4AE","#0B615E","#5882FA","#045FB4","#08298A",
       "#9F81F7","#7401DF","#3104B4","#CC2EFA","#6A0888",
       "#F781F4")

#生成正态分布的31个数据:
num<-rnorm(31, mean=5, sd=1)
num

#绘制dotplot来查看颜色效果
dtplt1<-dotchart(num, color = colwritten,cex = 1.8,  pch = 19)
dtplt1
image.png
barplot(num,col = colmerged, width = 0.03)
image.png

=====================================================

library(RColorBrewer)
display.brewer.all()#查看后选择以下行的行名
image.png
col2=brewer.pal(11, "Spectral") #只有11个
col3=brewer.pal(9, "RdBu") #只有11个
col4=brewer.pal(11, "PRGn") #只有11个
col5=brewer.pal(10, "BrBG") #只有11个

#写成一个颜色列
colmerged<-c(col2,col3,col4,col5)
#绘制图片
dtplt2<-dotchart(num, color = colmerged,cex = 1.8,  pch = 16)
dtplt2
image.png
#绘制dotplot来查看颜色效果
dtplt1<-dotchart(num, color = colmerged,cex = 1.8,  pch = 19)
dtplt1
image.png
colwritten<-c("#F3CECE","#F78181","#FF0000","#8A0808","#3B0B0B",
       "#F5BCA9","#F7BE81","#FF8000","#B45F04","#8A4B08",
       "#F2F5A9","#FFFF00","#AEB404","#868A08","#BEF781",
       "#80FF00","#5FB404","#58FAAC","#01DFA5","#00FFFF",
       "#04B4AE","#0B615E","#5882FA","#045FB4","#08298A",
       "#9F81F7","#7401DF","#3104B4","#CC2EFA","#6A0888",
       "#F781F4")

num<-rnorm(31, mean=5, sd=1)
num

dtplt1<-dotchart(num, color = colwritten,cex = 1.8,  pch = 19)
dtplt1
barplot(num,col = colwritten, width = 0.03)


library(RColorBrewer)
display.brewer.all()#查看后选择以下行的行名
col2=brewer.pal(11, "Spectral") #只有11个
col3=brewer.pal(9, "RdBu") #只有11个
col4=brewer.pal(11, "PRGn") #只有11个
col5=brewer.pal(10, "BrBG") #只有11个

colmerged<-c(col2,col3,col4,col5)

dtplt2<-dotchart(num, color = colmerged,cex = 1.8,  pch = 16)
dtplt2
barplot(num,col = colmerged, width = 0.03)

=================================================

上一篇 下一篇

猜你喜欢

热点阅读