Sc.pl.rank_genes_groups_heatmap colorbar order

sc.pl.rank_genes_groups() was desgined to display all the groups(such as all the clusters). When plot only a subset of the groups using the ‘groups’ parameter, the color bar would not change according to the subset groups, the orders are confused. here is the warning:
WARNING: Groups are not reordered because the groupby categories and the var_group_labels are different.

Then how to disply only a subset of the groups and keep the colorbar the same as that used by ‘louvain’ or ‘leiden’ clusters?

Hi, the colorbar spans through the maximum and minimum values found in the plotted expressions. If you select some groups, the maximum and minimum values may change and thus the color map changes. If you want to have a consistent colorbar use vmin and vmax.

The warning that you receive is not related to the colormap.