Data Visualization using Distribution Plot (Seaborn Library)

Home » News » Data Visualization using Distribution Plot (Seaborn Library)
Lets visualize our data with Distribution Plot which is present in Seaborn library. By default, Distribution Plot uses Histogram and KDE (Kernel Density Estimate). We can specify number of bins to the histogram as per our requirement. Please note that Distribution Plot is a univariate plot.


We can pass various parameters to distplot like bins, hist, kde, rug, vertical, color etc. 


Lets explore Distribution Plot by generating 150 random numbers.

Step 1: Import required libraries

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

Step 2: Generate 150 random numbers


num = np.random.randn(150)
num

Step 3: Explore data using Distribution Plot


sns.distplot(num)


Specify number of bins

sns.distplot(num, bins=20)


Remove histogram from distribution plot


sns.distplot(num, hist=False)


Remove KDE from distribution plot


sns.distplot(num, kde=False)


Add rug parameter to distribution plot


sns.distplot(num, hist=False, rug=True)


Add label to distribution plot


label_dist = pd.Series(num, name=”variable x”)
sns.distplot(label_dist)


Change orientation of distribution plot


sns.distplot(label_dist, vertical=True)


Add cosmetic parameter: color

sns.distplot(label_dist, color='red')


You can download my Jupyter notebook from here. I recommend to also try above code with Tips and Iris dataset.

Leave a Reply

Your email address will not be published. Required fields are marked *

New Providers
Binolla

The Broker
More then 2 million businesses
See Top 10 Broker

gamehag

Online game
More then 2 million businesses
See Top 10 Free Online Games

New Games
Lies of P

$59.99 Standard Edition
28% Save Discounts
See Top 10 Provider Games

COCOON

$24.99 Standard Edition
28% Save Discounts
See Top 10 Provider Games

New Offers
Commission up to $1850 for active user of affiliate program By Exness

Top Points © Copyright 2023 | By Topoin.com Media LLC.
Topoin.info is a site for reviewing the best and most trusted products, bonus, offers, business service providers and companies of all time.

Discover more from Topoin

Subscribe now to keep reading and get access to the full archive.

Continue reading