The inspiration for this question comes from breaks in pheatmap in R. The question is if I can define how "rough", how continuous/discrete my colouring and binning is in seaborn's heatmap. I have found a way how to do it using cmap and the number of colours used (eg. Discrete legend in seaborn heatmap plot). However, I have no idea how the assignment to those colour groups is done.
So the questions are, how are the data binned if I use cmap and force seaborn to use only a discrete set of colours=bins? How can I set it manually? Eg. in the case of R, I can set the breaks to be from 0 to 800 by step of 100 and pass it to the "breaks" argument.
breaksList = seq(0, 800, by = 100)
It is quite simple to use cmap and number of colours if my scale is linear but if I would like to have my bins=colorbar logarithmic or just not equally spaced, how would I do that?
To give a concrete example, let me present the example of flights data set. On the left is the original default plot, on the right, I choose 5 colours to have 5 bins. So how are defined the edges of those bins? Can I reset them so that I have eg. bins 0-200, 200-300, 300-400, 400-600, above 600? (I'm intentionally using unequal bins to show what I mean.)
# choose 5 colours to create 5 bins
cmap = sns.color_palette('rocket', n_colors=5)
# run this without the cmap argument to get the first image
flights = sns.load_dataset("flights")
flights = flights.pivot("month", "year", "passengers")
ax = sns.heatmap(flights, cmap = cmap)
Thanks.