Data Visualization using Violin Plot (Seaborn Library)

Home » News » Data Visualization using Violin Plot (Seaborn Library)
Lets visualize our data with Violin Plot which is present in Seaborn library.  


We can pass various parameters to violinplot like hue, split, inner (quartile, stick), scale, scale_hue, bandwidth (bw), palette, order etc. 


Lets explore Violin 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

Step 2: Load Tips datasets

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

Step 3: Explore data using Violin Plot

sns.violinplot(x=tips[‘tip'])


sns.violinplot(x='day', y='total_bill', data=tips)


Add hue and split parameter


sns.violinplot(x='day', y='total_bill', data=tips, hue='sex')


sns.violinplot(x='day', y='total_bill', data=tips, hue='sex', split=True)


sns.violinplot(x='day', y='total_bill', data=tips, hue='sex', palette='RdBu')

sns.violinplot(x='day', y='total_bill', data=tips, hue='sex', order=[‘Sat', ‘Sun', ‘Thur', ‘Fri'])


Add inner and scale parameter


sns.violinplot(x='day', y='total_bill', data=tips, hue='smoker', inner='quartile')


sns.violinplot(x='day', y='total_bill', data=tips, hue='smoker', inner='quartile', split='True')


sns.violinplot(x='day', y='total_bill', data=tips, hue='smoker', inner='quartile', split='True', scale='count')


sns.violinplot(x='day', y='total_bill', data=tips, hue='smoker', inner='stick', split='True', scale='count')


sns.violinplot(x='day', y='total_bill', data=tips, hue='smoker', inner='stick', split='True', scale='count', scale_hue=False)


sns.violinplot(x='day', y='total_bill', data=tips, hue='smoker', inner='stick', split='True', scale='count', scale_hue=False, bw=0.1)


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 Topoin

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

Continue reading