Search code examples
pythonmatplotlibcolormap

Colormap diverging from black instead of white?


I would like a diverging colormap that has another colour than white (preferably black) as it center color. Neither matplotlib or cmocean seems to have such a colormap. Is my best option to create an own colormap, or are there existing ones?


Solution

  • @JohanC put an obvious answer in their comment and I didn't see it because of the accepted answer which requires a less-known package:

    Seaborn supports arbitrary diverging palettes with black center

    hue_neg, hue_pos = 250, 15
    cmap = sns.diverging_palette(hue_neg, hue_pos, center="dark", as_cmap=True)
    

    example above in jupyter