Seaborn – KDE Plot Visualization


Seaborn – KDE Plot Visualization

Table Of Contents:

  • What Is KDE Plot ?
  • Where To Use KDE Plot ?
  • Examples Of KDE Plot ?

(1) What Is KDE Plot ?

(2) What Is Kernel ?

(3) What Is Density ?

(4) Where To Use KDE Plot ?

(4) Examples Of KDE Plot.

Example-1: Age Distribution of Titanic Passengers

import seaborn as sns
import matplotlib.pyplot as plt

# Load the Titanic dataset
titanic = sns.load_dataset("titanic")

# Create KDE plot for age
sns.kdeplot(data=titanic, x="age", fill=True)

# Add labels and title
plt.xlabel("Age")
plt.ylabel("Density")
plt.title("Age Distribution of Titanic Passengers")

# Show the plot
plt.show()

Example-2: Age Distribution By Gender

import seaborn as sns
import matplotlib.pyplot as plt

# Load the Titanic dataset
titanic = sns.load_dataset("titanic")

# Create KDE plot for age
sns.kdeplot(data=titanic, x="age", hue = 'sex', fill=True)

# Add labels and title
plt.xlabel("Age")
plt.ylabel("Density")
plt.title("Age Distribution of Titanic Passengers")

# Show the plot
plt.show()

Leave a Reply

Your email address will not be published. Required fields are marked *