I am wanting to overlay different 2D density plots over each other using the kdeplot() function from seaborn, however the color of the contours aren't appearing in the legend. How would I be able to update the legend with the color?
Code example:
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
sns.kdeplot(x = np.random.random(30), y = np.random.random(30), label = "dist1", ax=ax)
sns.kdeplot(x = np.random.random(30) + 1, y = np.random.random(30) + 1, label = "dist2", ax=ax)
ax.legend()
plt.show()

I'm using seaborn v0.12.0


Found a way to work around the issue. By extracting the colour in the colourcycle, you can manually set the colour of
kdeplot()as well as construct the handles for the legend.Output plot