0

As an example, I have a dataset ranging from 0 to 1.5. And the data is not distributed in normal distribution; from 0 to 0.1 is much more than 0.1 to 1.0. Now, I would like to allocate color map with different gradient using "vlag". Normally, the intermediate color (in this case white) is automatically allocated to the intermediate value (in this case 0.5). But I want to allocate white color to 0.1 and make heatmap with different color gradient; from 0(blue) to 0.1(white) and from 0.1(white) to 1.0(red) Can I do this by seaborn?

import copy
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np


cmap = copy.copy(plt.get_cmap("vlag"))
cmap.set_under('#002a85')
sns.heatmap(df, cmap=cmap,yticklabels =df_heat.iloc[:,0], vmin=1e-7)

enter image description here

cel
  • 30,017
  • 18
  • 97
  • 117
Minato
  • 1
  • Maybe a `LogNorm` helps here? See e.g. [Heatmap with logarithmic-scale colorbar](https://stackoverflow.com/questions/36898008/seaborn-heatmap-with-logarithmic-scale-colorbar). Or a [`TwoSlopeNorm`](https://matplotlib.org/3.5.0/api/_as_gen/matplotlib.colors.TwoSlopeNorm.html)? See e.g. [Coloring Matplotlib heatmap according to requirement](https://stackoverflow.com/questions/63606061/coloring-matplotlib-heatmap-according-to-requirement) – JohanC Apr 09 '22 at 12:29
  • That helped me a lot. Thank you Johan! I'l try this! – Minato Apr 10 '22 at 23:47

0 Answers0