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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值