ggplot2 PDF输出字体问题

作者: 落寞的橙子 | 来源:发表于2019-12-23 05:50 被阅读0次

    参考文章
    我的例子

    library(ggplot2)
    library(extrafont)
    font_import()
    fonts()
    loadfonts()
    Your_DEG_data$sigORnot = as.factor(ifelse(Your_DEG_data$padj < padj & abs(Your_DEG_data$log2FoldChange) > FC,
                                    ifelse(Your_DEG_data$log2FoldChange > FC ,'UP','DOWN'),'NOT'))
    g <-ggplot(data=Your_DEG_data, aes(x=log2FoldChange, y=-log10(Your_DEG_data[,"padj"]), color=sigORnot)) +
      geom_point(alpha=0.4, size=2) +
      theme_set(theme_set(theme_bw(base_size=20)))+
      xlab("Log2(Fold Change)") + ylab(paste0("-Log10(ajust p value)")) +
       scale_colour_manual(values = c('blue','grey','red'))+geom_hline(yintercept=(-log10(padj)),linetype=3)+geom_vline(xintercept=c(-(FC),FC),linetype=3) 
    g<-g+theme_classic()+
      theme(axis.title.x = element_text(size=20,family="Arial",face="bold",colour = "black"),
            axis.text.x = element_text(size=20,family="Arial",face="bold",colour = "black"),
            axis.title.y = element_text(family="Arial",size=20,colour = "black",face = "bold"),
            axis.text.y= element_text(size=20,family="Arial",face="bold",colour = "black"))
    g<-g+theme(axis.line = element_line(size=1))+theme(axis.ticks = element_line(size=1))
    g<-g+theme(legend.text=element_text(size=16,family="Arial",face="bold",colour = "black"),
               legend.title=element_text(size=20,family="Arial",face="bold",colour = "black"))
    ggsave("test.pdf",g,units = "in",width=5.5,height = 4.5)
    

    相关文章

      网友评论

        本文标题:ggplot2 PDF输出字体问题

        本文链接:https://www.haomeiwen.com/subject/heganctx.html