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

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

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()
palette='Set1'
是什么颜色?
如下图所示:

image-20221202143817195

posted @ 2022-12-03 23:43  bH1pJ  阅读(1838)  评论(0编辑  收藏  举报