R语言画箱线图

getwd()
library(readr)

datct<-read_delim("boxplot_clock_tissue.txt",delim = "\t")
datct
df = melt(datct)
#预览数据
head(df)
install.packages("ggplot")
install.packages("RColorBrewer")

install.packages("path/to/ggplot2.tar.gz", repos = NULL)  
install.packages("path/to/RColorSrewer.tar.gz", repos = NULL)

library(ggplot2)
library(RColorBrewer)

display.brewer.all()
mycol<-brewer.pal(n=3,name = "Set3")
mycol
mycol<-c("#8DD3C7","#FB8072","#80B1D3")#要查看代号运行mycol

library(ggpubr)
p<-ggboxplot(df,x="variable",y="value",color="variable",palette = mycol,legend="none",
          add ="jitter",add.params = list(size=3,jitter=0.1,alpha=0.5),outlier.shape = NA)+
  stat_compare_means(method = "kruskal.test",label.y = 4,label.x = 0.8,label = "p.format")+
  stat_compare_means(comparisons = list(c("G","F"),c("G","H"),c("F","H")),method="wilcox",label="p.signif")+
 theme(panel.grid = element_line(color = NA),panel.grid.minor = element_line(color = NA),
        panel.border = element_rect(fill = NA,color = NA),
        axis.text.x= element_text(size = 10,face ="italic",hjust = 0.5),
        axis.text.y = element_text(size = 10,face ="plain",hjust = 0.5),
        axis.title.y =element_text(vjust=0.2,size=12,face="bold"))
p

library(gridExtra)
library(cowplot)
ggsave("123.pdf",width=9,height=6)

  • 11
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值