I have a scatter plot on the left-hand side below, where there are lots of data points, and the figure on the right are corresponding density plot using seaborn.kdeplot()
. But unfortunately since the variance of the density is so large that kdeplot
fails to capture many details in other low-density area (e.g. there is basically no information about the density distribution on the top right).
Does anyone have any ways to fix this issue?
Thanks!
You can use the n_levels
parameter, i.e.
f, axes = plt.subplots(1, 3, figsize=(15, 5), sharex=True, sharey=True)
x, y = np.random.normal(0, 1, (2, 1000))
axes[0].scatter(x, y, s=5, c=".1")
sns.kdeplot(x, y, n_levels=10, ax=axes[1])
sns.kdeplot(x, y, n_levels=30, ax=axes[2])
f.tight_layout()