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


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, but changing those colors doesn’t seem to work for me.


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

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", }