Rug and KDE Plot for Tips

For the ‘tips’ dataset, visualize a rug plot of the ‘tip’ data, and overlay a KDE (Kernel Density Estimate) plot on top of it.

Example Output:

Use sns.rugplot for the rug plot and sns.kdeplot for the KDE.

import seaborn as sns
import matplotlib.pyplot as plt

def plot_rug_and_kde():
    tips_data = sns.load_dataset('tips')
    sns.rugplot(tips_data['tip'])
    sns.kdeplot(tips_data['tip'])
    plt.show()

plot_rug_and_kde()

 

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!