9

I am trying to plot a heatmap using seaborn. I have values from 0 to 5 and I need to make a blue-to-red color scale, with white being at 1, blue- below 1, and red - from 1 to 5.

How can I do that?

import seaborn as sns; sns.set()
hm=sns.heatmap(proportion, vmin=0, vmax=5, cmap='RdBu')

This is what I try to do, but it is not customized... 'proportion' is my variable. Is there anything I can do?

petezurich
  • 9,280
  • 9
  • 43
  • 57
Tom Smith
  • 181
  • 1
  • 11

1 Answers1

15

Maybe you mean to use the center argument,

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

data = np.random.rand(10,10)*5

ax = sns.heatmap(data, vmin=0,vmax=5,center=1,cmap="RdBu_r")

plt.show()
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712