• Scanpy plot umap的color编码, Scanpy 的color map 如何设置?


    Scanpy plot umap的color编码, Scanpy 的color map 如何设置?关键词palette(调色板)

    image-20221129114338266

    https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.umap.html?highlight=pl.umap#scanpy.pl.umap

    https://scanpy.discourse.group/t/specifying-color-of-umap-cluster/538/2

    image-20221129114510407

    自己选择喜欢的颜色:

    palette

    CD4 : "RED"

      louvain结果的颜色,竟然可以直接被修改。louvain结果的颜色存在了.uns['louvain_colors']变量中

      image-20221129115034150

      scanpy color 的palette可以选择的颜色有哪些?

      image-20221129115858322

      微信图片转换为文字,太强了;

      black
      t
      dimgrey
      dimgraygreygraydarkgraydarkgrey
      silver
      lightgrey
      lightgraygainsborowhitesmoke
      whitew
      snow
      rosybrown
      lightcoral
      indianred
      brown
      firebrick
      maroon
      darkred
      red
      mistyrose
      salmon
      tomato
      darksalmon
      coral
      orangered
      lightsalmon
      sienna
      seashell
      chocolate
      saddlebrown
      sandybrownpeachpuffperu
      linen
      bisque
      darkorange
      burlywood
      antiquewhitetan
      navajowhiteblanchedalmondpapayawhip
      moccasin
      orange
      wheat
      oldlace
      floralwhitedarkgoldenrodgoldenrodcornsilkgold
      lemonchiffonkhaki
      palegoldenrod
      darkkhaki
      ivory
      beige
      lightyellow
      lightgoldenrodyellow
      olive
      yellow
      olivedrab
      yellowgreendarkolivegreengreenyellowchartreuselawngreenhoneydewdarkseagreenpalegreenlightgreen
      forestgreen
      limegreen
      darkgreengreen
      0
      lime
      seagreen
      mediumseagreenspringgreen
      mintcream
      mediumspringgreenmediumaquamarine
      aquamarine
      turquoise
      lightseagreen
      mediumturquoise
      azure
      lightcyan
      paleturquoise
      darkslategray
      darkslategrey
      teal
      darkcyan
      c
      cyan
      aqua
      darkturquoise
      cadetblue
      powderblue
      lightbluedeepskyblue
      skyblue
      lightskybluesteelbluealicebluedodgerbluelightslategreylightslategrayslategrey
      slategray
      lightsteelblue
      cornflowerblue
      royalblue
      ghostwhite
      lavender
      midnightblue
      navy
      darkblue
      mediumblueblue6
      slateblue
      darkslateblue
      mediumslateblue
      mediumpurplerebeccapurple
      blueviolet
      indigo
      darkorchid
      darkviolet
      mediumorchidthistleplum
      violetpurpledarkmagentammagentafuchsiaorchidmediumvioletreddeeppinkhotpinklavenderblushpalevioletredcrimson
      pink
      lightpink
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38
      • 39
      • 40
      • 41
      • 42
      • 43
      • 44
      • 45
      • 46
      • 47
      • 48
      • 49
      • 50
      • 51
      • 52
      • 53
      • 54
      • 55
      • 56
      • 57
      • 58
      • 59
      • 60
      • 61
      • 62
      • 63
      • 64
      • 65
      • 66
      • 67
      • 68
      • 69
      • 70
      • 71
      • 72
      • 73
      • 74
      • 75
      • 76
      • 77
      • 78
      • 79
      • 80
      • 81
      • 82
      • 83
      • 84
      • 85
      • 86
      • 87
      • 88
      • 89
      • 90
      • 91
      • 92
      • 93
      • 94
      • 95
      • 96
      • 97
      • 98
      • 99
      • 100
      • 101

      天啊,这个可以通过代码直接得到:

      import matplotlib.pyplot as plt
      from matplotlib import colors as mcolors
      
      
      colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
      
      # Sort colors by hue, saturation, value and name.
      by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgba(color)[:3])), name)
                      for name, color in colors.items())
      sorted_names = [name for hsv, name in by_hsv]
      
      n = len(sorted_names)
      ncols = 4
      nrows = n // ncols
      
      fig, ax = plt.subplots(figsize=(12, 10))
      
      # Get height and width
      X, Y = fig.get_dpi() * fig.get_size_inches()
      h = Y / (nrows + 1)
      w = X / ncols
      
      for i, name in enumerate(sorted_names):
          row = i % nrows
          col = i // nrows
          y = Y - (row * h) - h
      
          xi_line = w * (col + 0.05)
          xf_line = w * (col + 0.25)
          xi_text = w * (col + 0.3)
      
          ax.text(xi_text, y, name, fontsize=(h * 0.8),
                  horizontalalignment='left',
                  verticalalignment='center')
      
          ax.hlines(y + h * 0.1, xi_line, xf_line,
                    color=colors[name], linewidth=(h * 0.8))
      
      ax.set_xlim(0, X)
      ax.set_ylim(0, Y)
      ax.set_axis_off()
      
      fig.subplots_adjust(left=0, right=1,
                          top=1, bottom=0,
                          hspace=0, wspace=0)
      plt.show()
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38
      • 39
      • 40
      • 41
      • 42
      • 43
      • 44
      • 45
      palette='Set1'
      是什么颜色?
      如下图所示:
      • 1
      • 2

      image-20221202143817195

    • 相关阅读:
      谷粒商城实战笔记-142-性能压测-压力测试-Apache JMeter安装使用
      利用EFK对日志进行采集
      ERP系统有哪些优点和缺点?
      Power BI 和 Tableau的区别
      《微信小程序开发从入门到实战》学习二十五
      Vue+ElementUI+Bootstrap+Fetch实现学生信息修改页面,并与后端交互修改数据库信息
      数据库设计规范
      【刷爆LeetCode】七月算法集训(20)二叉搜索树
      springboot项目前后端搭建
      FreeRTOS的学习(三)—— 信号量之二值信号量
    • 原文地址:https://blog.csdn.net/Hodors/article/details/128168289