- #80 Contour plot with seaborn
- #80 Density plot with seaborn
- #80 Contour plot with seaborn
Here are 3 contour plots made using the seaborn python library. You have to provide 2 numerical variables as input (one for each axis). The function will calculate the kernel density estimate and represent it as a contour plot or density plot. Note that you can use the same argument as for a 1D density plot to custom your chart. ‘Cmap’ allows you to choose a colour palette, ‘shade’ controls the presence of a shade and so on..
# library & dataset import seaborn as sns df = sns.load_dataset('iris') # Basic 2D density plot sns.set_style("white") sns.kdeplot(df.sepal_width, df.sepal_length) #sns.plt.show() # Custom it with the same argument as 1D density plot sns.kdeplot(df.sepal_width, df.sepal_length, cmap="Reds", shade=True, bw=.15) # Some features are characteristic of 2D: color palette and wether or not color the lowest range sns.kdeplot(df.sepal_width, df.sepal_length, cmap="Blues", shade=True, shade_lowest=True, ) sns.plt.show()
Hi! I tried to reproduce the third plot but it doesn’t have the black contour lines. Is there some missing information in the instruction for plotting it?