Skip to content Skip to sidebar Skip to footer

Change Image Limits Of Seaborn Kdeplot

When I make a seaborn.kdeplot with the shade parameter set as True, the background is white. This background does not extend to the whole plot if there is something else that is pl

Solution 1:

That works:

import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

points = np.random.multivariate_normal([0, 0], [[1, 2], [2, 20]], size=1000)

plt.plot([-3, 3],[0,60])

ax = sns.kdeplot(points, shade=True)
ax.collections[0].set_alpha(0)

plt.show()

enter image description here

Solution 2:

Well you can do so by using the set_style parameter

import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

plt.plot([-3, 3],[0,60])

points = np.random.multivariate_normal([0, 0], [[1, 2], [2, 20]], size=1000)
sns.kdeplot(points)
sns.set_style("white") # HERE WE SET THE BACKGROUND TO BE WHITE

plt.show()

The code above will produce a plot like this:

enter image description here

Post a Comment for "Change Image Limits Of Seaborn Kdeplot"