Python Forum
How to manually define color bar scale in seaborn heatmap
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to manually define color bar scale in seaborn heatmap
#4
Hi Rajesh,

When we create seaborn heatmap then automatically color bar also generate. Depend on creator requirement, we can modify it. You want to display ticks, so use cbar_kws sns.heatmap() parameter and pass keys(ticks) and values mapping for change the style and format of seaborn heatmap color bar

import numpy as np; np.random.seed(0)
import seaborn as sns; sns.set()

uniform_data = np.random.rand(10, 12)

# color bar keyword arguments
cbar_kws = {"shrink":1,
            'extend':'min', 
            'extendfrac':.1, 
            "drawedges":True, 
            'ticks': [0.0, 0.2, 0.4, 0.5, 0.7, 0.8, 1.0], # set ticks of color bar
            'label':'Color Bar'}

ax = sns.heatmap(uniform_data, cbar_kws=cbar_kws, vmin=0, vmax=1)
Reply


Messages In This Thread
RE: How to manually define color bar scale in seaborn heatmap - by RudraMohan - Sep-08-2019, 11:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  manually input data jpatierno 0 347 Nov-10-2023, 02:32 AM
Last Post: jpatierno
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 1,041 Oct-25-2023, 09:09 AM
Last Post: codelab
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,694 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  How to properly scale text in postscript conversion to pdf? philipbergwerf 3 1,140 Nov-07-2022, 01:30 PM
Last Post: philipbergwerf
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,425 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  Installing and Using Seaborn Led_Zeppelin 4 2,592 Jun-07-2022, 09:44 PM
Last Post: snippsat
  KeyError: 0 when trying to dedupe and match records at scale Catalytic 1 2,189 Apr-07-2022, 06:34 PM
Last Post: deanhystad
  How to increase the size of a png picture for the heatmap of the correlation? lulu43366 9 3,544 Oct-06-2021, 04:15 PM
Last Post: deanhystad
  How to remove a column or two columns in a correlation heatmap? lulu43366 3 5,244 Sep-30-2021, 03:47 PM
Last Post: lulu43366
  Matplotlib scale julienhofmann 0 1,814 Apr-04-2021, 08:50 AM
Last Post: julienhofmann

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020