0

So I am relatively new to seaborn and I want to create a kdeplot which can show the relation between two of my datasets (almost 2000 single column entries).

The plot comes out fine, but the cbar shows values in decimals (from 0.000065 to 0.002356). How do I change that to 0 to 2500?? (Check the image attached)

I tried the vmin and vmax module, but doesn't show a proper result.

Can someone help me?

Sample Data:

y_test = [463.26, 444.37, 488.56, 446.48]
y_pred = [432.84, 458.53, 466.75, 445.92]

Sample Plot 1

sns.kdeplot(y_test,y_pred, shade=True, 
        cmap='plasma', alpha= 0.9, cbar=True) 
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • 2
    Well, the colorbar shows the [density](https://en.wikipedia.org/wiki/Probability_density_function). The density is supposed to have a volume (the integral) of 1 over the complete area. You could set ´cbar=False´ to not show this. Changing the values doesn't seem to make much sense. – JohanC Dec 16 '21 at 14:18
  • Thanks for the response. I'm aware, but I have been asked to demonstrate the density cluster count instead of the integral of 1 over the region. That's why I need help, if you know a way – user17692646 Dec 17 '21 at 11:38
  • So, you don't want a `kdeplot`. If you want a histogram, you could use `sns.histplot`. The [docs](https://seaborn.pydata.org/generated/seaborn.histplot.html) have some examples, starting with `sns.histplot(penguins, x="bill_depth_mm", y="body_mass_g")`. The kde plot is a bit similar to a histogram with many small bins, and then smoothed out and normalized (total volume of 1). Note that the heights of a histogram get lower when smaller bins are used. (The sum of all the heights should be the number of samples.) – JohanC Dec 17 '21 at 14:37
  • Hey, so I tried your approach with a combination of kde. It works perfectly and the histogram count shows me exactly what I ned. Thanks a lot. – user17692646 Dec 20 '21 at 05:02

0 Answers0