Search code examples
pythonpython-3.xseabornkernel-density

Python - Display Seaborn KDE Plot


I want to display Seaborn KDE Plot but I couldn't get to display it with a normal show method. How shall I do it?

import numpy as np 
from scipy.fftpack import dct
import seaborn 

sample1 = dct(np.random.rand(100))
sample2 = dct(np.random.rand(30))
seaborn.kdeplot(sample1, color="r")
seaborn.kdeplot(sample2, color="b")

Solution

  • Try

    import numpy as np 
    from scipy.fftpack import dct
    import matplotlib.pyplot as plt
    import seaborn as sns
    sns.set()
    
    sample1 = dct(np.random.rand(100))
    sample2 = dct(np.random.rand(30))
    sns.kdeplot(sample1, color="r")
    sns.kdeplot(sample2, color="b")
    plt.show()
    
    

    Output enter image description here