Seaborn – Strip Plot Visualization


Seaborn – Strip Plot Visualization

Table Of Contents:

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

(1) What Is Strip Plot ?

(2) Where To Use Strip Plot ?

(3) Examples Of Strip Plot ?

Example-1: Strip Plot of Fare Prices by Class

import seaborn as sns
import matplotlib.pyplot as plt

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

# Create a strip plot for fare
sns.stripplot(data=titanic, x="class", y="fare", jitter=False)

plt.xlabel("Passenger Class")
plt.ylabel("Fare ($)")
plt.title("Strip Plot of Fare Prices by Class")
plt.show()

Example-2: Strip Plot with Jitter (Spreading Out Points)

import seaborn as sns
import matplotlib.pyplot as plt

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

# Create a strip plot for fare
sns.stripplot(data=titanic, x="class", y="fare",jitter=True)

plt.xlabel("Passenger Class")
plt.ylabel("Fare ($)")
plt.title("Strip Plot of Fare Prices by Class")
plt.show()

Example-3: Combining Strip Plot with Box Plot

import seaborn as sns
import matplotlib.pyplot as plt

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

# Create a strip plot for fare
sns.boxplot(data=titanic, x="class", y="fare")
sns.stripplot(data=titanic, x="class", y="fare", color="black", alpha=0.5)

plt.xlabel("Passenger Class")
plt.ylabel("Fare ($)")
plt.title("Strip Plot of Fare Prices by Class")
plt.show()

Leave a Reply

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