• 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

    • 相关阅读:
      代码随想录二刷第一天(Python)
      抗疫行动题材网页设计 大学生最美逆行者感动人物网页代码 众志成城万众一心抗击疫情HTML网页设计
      猿创征文|【Maven】分模块开发、依赖管理、聚合、继承、属性
      Integer对象和int值
      亲测可用:Axios携带自定义的Cookie解决方案
      Golang 接口 interface
      java毕业设计宠物交易平台Mybatis+系统+数据库+调试部署
      【782. 变为棋盘】
      Shell 正则表达式
      【C++】头文件chrono
    • 原文地址:https://blog.csdn.net/Hodors/article/details/128168289