Seaborn – Box Plot Visualization
Table Of Contents:
- What Is Box Plot ?
- Where To Use Box Plot ?
- Examples Of Box Plot ?
(1) What Is Box Plot ?
(2) Where To Use Box Plot ?
(3) Examples Of Box Plot ?
Example-1: Box Plot of Fare Prices
import seaborn as sns
import matplotlib.pyplot as plt
# Load Titanic dataset
titanic = sns.load_dataset("titanic")
# Create Box Plot for fare
sns.boxplot(data=titanic, x="fare")
plt.xlabel("Fare ($)")
plt.title("Box Plot of Fare Prices")
plt.show()
Example-2: Box Plot Comparing Passenger Classes
import seaborn as sns
import matplotlib.pyplot as plt
# Load Titanic dataset
titanic = sns.load_dataset("titanic")
# Create Box Plot for fare
sns.boxplot(data=titanic, x="class", y="fare")
plt.xlabel("Fare ($)")
plt.title("Box Plot of Fare Prices")
plt.show()
Example-3: Box Plot with hue (Gender-wise Comparison)
import seaborn as sns
import matplotlib.pyplot as plt
# Load Titanic dataset
titanic = sns.load_dataset("titanic")
# Create Box Plot for fare
sns.boxplot(data=titanic, x="class", y="fare", hue = 'sex')
plt.xlabel("Fare ($)")
plt.title("Box Plot of Fare Prices")
plt.show()

