'Control order of Tab10 colors in colormap

I would like to get a colormap with the first two colors of the Tab10 palette (blue and orange). But

import matplotlib.pyplot as plt
plt.get_cmap('tab10', 2)

gives me the first and the last color of the palette

cmap

Is there an easy way to control the order of the colors? My intention is to have a color scheme identical to the matplotlib default for categorical values.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source