#74 Density plot of several variables





Sometimes it is useful to plot the distribution of several variables on the same plot to compare them. This is possible using the kdeplot function of seaborn several times:







# library and dataset
import seaborn as sns
df = sns.load_dataset('iris')

# plot of 2 variables
p1=sns.kdeplot(df['sepal_width'], shade=True, color="r")
p1=sns.kdeplot(df['sepal_length'], shade=True, color="b")

Leave a Reply

Your email address will not be published.