[R语言]柱状图 自动颜色 横向 添加…

时间:2022-05-29 18:01:48
文件:‘picture3-summary_SNP_Sample_067754N.txt’
region counts
splice_region 2748
5_prime_UTR 4559
3_prime_UTR 33147
upstream 75401
downstream 85138
intergenic_region 57160
intron 447545
exon 41060

library(ggplot2)options(scipen=3)  #不使用科学计数法df1<-read.table('picture3-summary_SNP_Sample_067754N.txt',header=TRUE,sep="\t")ggplot(df1,aes(x=region,y=counts,fill=region)) #fill=region自动颜色+ geom_bar(stat='identity')  #以数字直接作为Y轴+ coord_flip()  #横向+ geom_text(aes(label = counts, vjust = 0.5, hjust = -0.2)) #柱状图右方添加文本+ theme(legend.position='none')  #去掉标签+ ylim(0,500000)  #更改Y轴范围[R语言]柱状图&nbsp;自动颜色&nbsp;横向&nbsp;添加…