Seaborn – Violin Plot Visualization
Table Of Contents:
- What Is Violin Plot ?
- Where To Use Violin Plot ?
- Examples Of Violin Plot ?
(1) What Is Violin Plot ?


(2) Where To Use Violin Plot ?

(3) Examples Of Violin Plot.
Example-1: Basic Violin Plot
import seaborn as sns
import matplotlib.pyplot as plt
# Load Titanic dataset
titanic = sns.load_dataset("titanic")
# Create a violin plot for passenger fare
sns.violinplot(data=titanic, x="fare")
plt.xlabel("Fare ($)")
plt.title("Violin Plot of Passenger Fare")
plt.show()


Example-2: Comparing Fare Distribution Across Passenger Classes
import seaborn as sns
import matplotlib.pyplot as plt
# Load Titanic dataset
titanic = sns.load_dataset("titanic")
# Create a violin plot for passenger fare
sns.violinplot(data=titanic, x="class", y="fare")
plt.xlabel("Fare ($)")
plt.title("Violin Plot of Passenger Fare")
plt.show()

Example-3: Violin Plot with Hue (Gender Comparison)
import seaborn as sns
import matplotlib.pyplot as plt
# Load Titanic dataset
titanic = sns.load_dataset("titanic")
# Create a violin plot for passenger fare
sns.violinplot(data=titanic, x="class", y="fare", hue="sex", split=True)
plt.xlabel("Fare ($)")
plt.title("Violin Plot of Passenger Fare")
plt.show()
