Data Visualization using Joint Plot (Seaborn Library)

Home » News » Data Visualization using Joint Plot (Seaborn Library)
Lets visualize our data with Joint Plot which is present in Seaborn library. By default, Joint Plot uses Scatter Plot and Histogram. Joint Plot can also display data using Kernel Density Estimate (KDE) and Hexagons. We can also draw a Regression Line in Scatter Plot. By using spearmanr function, we can print the correlation between two variables.


We can pass various parameters to jointplot like kind (reg, hex, kde), stat_func(spearmanr), color, size, ratio etc.


Spearmanr Parameter

  • Spearmanr parameter displays the correlation between two variables.
  • Value varies between -1 and +1 with 0 implying no correlation.
  • Correlations of -1 or +1 imply an exact monotonic relationship. 
  • Positive correlations imply that as x increases, so does y. Negative correlations imply that as x increases, y decreases.
  • Spearmanr correlation does not assume that both variables are normally distributed.
For more details on spearmanr parameter, please visit documentation.

Lets explore Joint Plot using Tips dataset.

Step 1: Import required libraries

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
from scipy.stats import spearmanr

Step 2: Load Tips dataset


tips=sns.load_dataset(‘tips')
tips.head()


Step 3: Explore data using Joint Plot

sns.jointplot(x='total_bill', y='tip', data=tips)


Add regression line to scatter plot and kernel density estimate to histogram

sns.jointplot(x='total_bill', y='tip', data=tips, kind='reg') 


Display kernel density estimate instead of scatter plot and histogram


sns.jointplot(x='total_bill', y='tip', data=tips, kind='kde')


Display hexagons instead of points in scatter plot


sns.jointplot(x='total_bill', y='tip', data=tips, kind='hex') 


Display correlation using spearmanr function

sns.jointplot(x='total_bill', y='tip', data=tips, stat_func=spearmanr)


Cosmetic parameters like color, size and ratio


sns.jointplot(x='total_bill', y='tip', data=tips, color='green')


sns.jointplot(x='total_bill', y='tip', data=tips, ratio=4, size=6)


You can download my Jupyter notebook from here. I recommend to also try above code with 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 Top Points

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

Continue reading