Scatter Plot Matrices

作者: JeremyL | 来源:发表于2018-11-02 23:21 被阅读55次

    lattice包提供了很多画图函数,这儿我们使用lattice包splom()画散点矩阵图和parallelplot()画平行坐标图;

    记得有一次帮别人画基因cluster随时间表达模式图;每个基因在各个时刻表达值使用一条折线表示,当时使用了循环一条线一条线的画;现在可以使用parallelplot()这个函数;

    Draw Conditional Scatter Plot Matrices and Parallel Coordinate Plots

    Usage
    splom(x, data, ...)
    parallelplot(x, data, ...)
    

    x: 可以是表达式,也可以是data.frame;
    表达式格式:~ x | g1 * g2 ;x可以是数据框或者矩阵;g1,g2是数据因子;展示g1 * g2 各水平组合下,x中各数据分布情况;
    group: 选择分组的因子

    library(lattice)
    
    super.sym <- trellis.par.get("superpose.symbol")
    splom(~iris[1:4], groups = Species, data = iris,
          panel = panel.superpose,
          key = list(title = "Three Varieties of Iris",
                     columns = 3, 
                     points = list(pch = super.sym$pch[1:3],
                                   col = super.sym$col[1:3]),
                     text = list(c("Setosa", "Versicolor", "Virginica"))))
    
    splom(~iris[1:3]|Species, data = iris, 
          layout=c(2,2), pscales = 0,
          varnames = c("Sepal\nLength", "Sepal\nWidth", "Petal\nLength"),
          page = function(...) {
            ltext(x = seq(.6, .8, length.out = 4), 
                  y = seq(.9, .6, length.out = 4), 
                  labels = c("Three", "Varieties", "of", "Iris"),
                  cex = 2)
          })
    
    parallelplot(~iris[1:4] | Species, iris) 
    
    parallelplot(~iris[1:4], iris, groups = Species,
                 horizontal.axis = FALSE, scales = list(x = list(rot = 90)))
    

    相关文章

      网友评论

        本文标题:Scatter Plot Matrices

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