ggplot点的大小和文本

pr<-ggplot(sortdf,aes(GeneRatio,GO.Term,size=Count,
                      colour=qvalue))+#横坐标、纵坐标、颜色代表p-value
  geom_point()+#圆点的大小代表组内基因数
  scale_color_gradientn(colours=c("red","blue"))+#可以自己改颜色
  #圆点的大小代表Number of significant genes
  #scale_size_continuous(range = c(4,7))+#圆点的大小范围
  scale_x_continuous(limits = c(0.01,0.1))+#设置x轴范围
  theme_bw(15)+#背景变成白色
  ylab("")+
  scale_y_discrete(position = "right",labels=function(x) str_wrap(x, width=40))+#把term放到右侧,labels 用来给文本分成两行
  theme(legend.position=c(1,0),legend.justification = c(1,0))+#legend画在左下角
  #下面两行让legend融入图
  theme(legend.background = element_blank())+#移除legend整体的边框
  theme(legend.key = element_blank())+#移除legend每个项目周围的边框
  theme(title=element_text(family="myFont",size=12,color="black",
                           face="plain",hjust=0.2,lineheight=0.2),
        axis.title.x=element_text(size=10,face="plain",color="black",hjust=0.5),
        axis.title.y=element_text(size=14,color="black",hjust=0.5,angle=45),
        axis.text.x=element_text(family="myFont",size=8,color="black"),
        axis.text.y.right=element_text(family="myFont",size=12,face="plain",color="black"))

  
##设置点的大小  
pr+ scale_size(range=c(5, 6))
##排序点的位置
pr=pr+guides(size = guide_legend(order=1))
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。