zoukankan      html  css  js  c++  java
  • R 配色

    virids调色板

    安装和加载,及测试代码

    install.packages("viridis")
    library(viridis)
    
    library(ggplot2)
    ggplot(data.frame(x = rnorm(10000), y = rnorm(10000)), aes(x = x, y = y)) +
      geom_hex() + coord_fixed() +
      scale_fill_viridis() + theme_bw()
    

    热图调色

    seed(1234)
    matrix <-  matrix(rnorm(100), 20, 10)
    matrix[1:10, seq(1, 10, 2)]   <- matrix[1:10, seq(1, 10, 2)] + 3
    matrix[11:20, seq(2, 10, 2)] <- matrix[11:20, seq(2, 10, 2)] + 2
    matrix[15:20, seq(2, 10, 2)] <- matrix[15:20, seq(2, 10, 2)] + 4
    colnames(matrix)  <- paste("Test", 1:10, sep = "")
    rownames(matrix) <- paste("Gene", 1:20, sep = "")
    
    # default
    pheatmap(matrix)
    # viridis
    pheatmap(test, color = viridis(7))
    

    viridis提供的配色方案

    avatar

    RColorBrewer

    col = RColorBrewer::brewer.pal(name = "Blues", n = 9)
    col
    [1] "#F7FBFF" "#DEEBF7" "#C6DBEF" "#9ECAE1" "#6BAED6" "#4292C6" "#2171B5"
    [8] "#08519C" "#08306B"
    
    setNames(RColorBrewer::brewer.pal(name = "Blues", n = 7), c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"))
      Sunday    Monday   Tuesday Wednesday  Thursday    Friday  Saturday
    "#EFF3FF" "#C6DBEF" "#9ECAE1" "#6BAED6" "#4292C6" "#2171B5" "#084594"
    

    也可以用list代替vector

     setNames(RColorBrewer::brewer.pal(name = "Blues", n = 7), list("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"))
    
  • 相关阅读:
    static的全部用法收集整理
    文思创新复试及一些自己的思考
    “一碗牛肉面”引发的管理难题
    信必优面试实录
    我做PM(项目经理)这段时间...
    什么是面向对象?
    沟通
    体会Bind和Eval的不同用法
    北京艾德思奇科技有限公司面试实录
    今天去sony公司面试实录
  • 原文地址:https://www.cnblogs.com/yuwq/p/11504555.html
Copyright © 2011-2022 走看看