Home > OS >  How to combine 2 discrete colormaps in matpotlib
How to combine 2 discrete colormaps in matpotlib

Time:01-13

I want to create a stacked bar chart with more than 20 discrete classes. The largest discrete colormap only has 20 colors, which is note enough for me. Below are the discrete colormaps:

enter image description here

My idea is to combine/concatenate colormaps tab20b and tab20c such that I have 40 discrete colors. Is this easily doable in python?

CodePudding user response:

Create your custom colormap:

from matplotlib import cm, colors

cmap = colors.ListedColormap(cm.tab20.colors   cm.tab20c.colors, name='tab40')

enter image description here

  • Related