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()
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.