# How to assign the specific colors to cell types on umaps across different dataset?

**URL:** <https://discourse.scverse.org/t/how-to-assign-the-specific-colors-to-cell-types-on-umaps-across-different-dataset/1244>\
**Category:** scanpy\
**Created:** [March 20, 2023, 6:05am UTC](https://discourse.scverse.org/t/how-to-assign-the-specific-colors-to-cell-types-on-umaps-across-different-dataset/1244 "2023-03-20T06:05:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Szym29](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/szym29/32/589_2.png) [@Szym29](https://discourse.scverse.org/u/Szym29)\
**Post date:** [March 20, 2023, 6:05am UTC](https://discourse.scverse.org/t/how-to-assign-the-specific-colors-to-cell-types-on-umaps-across-different-dataset/1244/1 "2023-03-20T06:05:42Z")

</div>

Hi,

I am using scanpy to plot umaps for two different datasets and their cell types have some intersections but not exactly the same. I was wondering if there is a way to plot the umap with fixed colors.

I tried palette and colormaps, but neither worked for me. I also saw something like ‘cell\_type\_colors’ after I running sc.pl.umap(), but changing those colors doesn’t seem to work for me.

Thanks

---

<div class="post-metadata">

**Author:** ![maflot](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/maflot/32/207_2.png) [@maflot](https://discourse.scverse.org/u/maflot)\
**Post date:** [March 20, 2023, 9:41am UTC](https://discourse.scverse.org/t/how-to-assign-the-specific-colors-to-cell-types-on-umaps-across-different-dataset/1244/2 "2023-03-20T09:41:49Z")

</div>

You should be able to pass a dictionary mapping the labels to colors as `palette` argument to the `sc.pl.umap` function.

---

<div class="post-metadata">

**Author:** ![Szym29](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/szym29/32/589_2.png) [@Szym29](https://discourse.scverse.org/u/Szym29)\
**Post date:** [March 20, 2023, 1:02pm UTC](https://discourse.scverse.org/t/how-to-assign-the-specific-colors-to-cell-types-on-umaps-across-different-dataset/1244/3 "2023-03-20T13:02:06Z")

</div>

Hi maflot,

Thanks for your response! It worked for me. I didn’t pass the color dictionary in the correct format previously.

For those who might have the same question. Please follow the format like  
`palette={ "CD4 T cells": "red", "CD8 T cells": "orange", "B cells": "green", "NK cells": "blue", }`
