美文网首页R
【R>>theme】主题相关函数

【R>>theme】主题相关函数

作者: 高大石头 | 来源:发表于2021-06-08 00:38 被阅读0次

    ggplot2有丰富的主题集,现总结下适合发表的主题系列。

    rm(list = ls())
    library(ggplot2)
    library(ggsci)
    
    p <- ggplot(iris,aes(Sepal.Length,
                    Sepal.Width,
                    color=Species,
                    shape=Species))+
      geom_point(size=6,
                 alpha=0.8,
                 show.legend = F)+
      scale_color_nejm()+
      theme(plot.margin = unit(rep(1.2,4),"cm")) #figure四周到边缘距离
    

    1.ggplot2自带主题

    p1 <- p+theme_bw()+labs(title = "theme_bw()")
    p2 <- p+theme_classic()+labs(title = "theme_classic()")
    p3 <- p+theme_minimal()+labs(title = "theme_minimal()")
    library(patchwork)
    p+p1+p2+p3
    
    image.png

    2.egg包主题

    library(egg)
    p4 <- p+theme_article()+labs(title = "egg::theme_article()")
    p5 <- p+theme_presentation()+labs(title = "egg::theme_presentation()")
    p4+p5
    
    image.png

    3.ggpubr

    library(ggpubr)
    p6 <- p+theme_pubr()+labs(title = "ggpubr::theme_pubr()")
    p7 <- p+theme_classic()+labs(title = "ggpubr::theme_classic()")
    p8 <- p+theme_classic2()+labs(title = "ggpubr::theme_classic2()")
    p6+p7+p8
    
    image.png

    4.bigstatsr

    library(bigstatsr)
    p9 <- p+theme_bigstatsr()+labs(title = "bigstatsr::theme_bigstatsr()")
    p9
    
    image.png

    5. ggprism

    library(ggprism)
    p10 <- p+theme_prism()+labs(title = "ggprism::theme_prism()")
    p10
    
    image.png

    其实ggplot2相关的主题有很多,但这些都不重要,找到最适合自己的,才是最好的!

    参考资料:

    Available theme for ggplot2

    相关文章

      网友评论

        本文标题:【R>>theme】主题相关函数

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