Distribution of Diamond Prices for Each Cut

For the Diamonds dataset, plot a violin plot showcasing the distribution of the price for each cut of the diamond.

Example Output:

Utilize the sns.violinplot function, and the Diamonds dataset can be fetched using sns.load_dataset('diamonds').

import seaborn as sns
import matplotlib.pyplot as plt

def plot_diamond_prices():
    diamonds_data = sns.load_dataset('diamonds')
    sns.violinplot(x='cut', y='price', data=diamonds_data)
    plt.title('Distribution of Diamond Prices for Each Cut')
    plt.show()

plot_diamond_prices()

 

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!