Python: How to centre a colorbar at a defined value for Seaborn Heatmap?

前端 未结 1 1356
独厮守ぢ
独厮守ぢ 2021-01-19 02:32

I am trying to plot a heatmap using seaborn. So, 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条回答
  • 2021-01-19 03:16

    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()
    
    0 讨论(0)
提交回复
热议问题