Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Boxplot in seaborn:

Get Datasets Name:
import seaborn as sns
import matplotlib.pyplot as plt
sns.get_dataset_names()

#load specific dataset:
sns.load_dataset('attention')
#store in variable
data=sns.load_dataset('exercise')
print(data)

Program:

import seaborn as sns
import matplotlib.pyplot as plt

df = sns.load_dataset('iris')
# print(df.head())
a=df.head()  #get first five row by default
print(a["sepal_width"])
sns.boxplot( y=a["sepal_length"] );
plt.show()

OUTPUT:


Program 2:

import Seaborn as sns
import matplotlib.pyplot as plt

df = sns.load_dataset('exercise')
df.head()

sns.boxplot( y=df["time"], x=df["pulse"] );
plt.show()

OUTPUT:

Create Boxplot from dataframe data:

import seaborn as sns
import pandas as p
import matplotlib.pyplot as plt

# df = sns.load_dataset('exercise')
# df.head()
a=p.DataFrame({"a":[10,33,44,58,44],"b":[93,44,96,66,69]})

sns.boxplot( y=a["a"], x=a["b"] );
plt.show()

OUTPUT:

Program:

df = sns.load_dataset('exercise')   '//load data from seaborn dataset
df.head()  //select first 5 row
graph=sns.boxplot( y=df["time"], x=df["pulse"] );         //plot graph giving x axis=time
graph.axes.set_title("My Graph",     
                    fontsize=16)                      //give graph title

graph.set_xlabel("Marks",
                fontsize=14)

graph.set_ylabel("Age",
                fontsize=14)

graph.figure.savefig("box.jpg",
                    format='jpeg',                 //  save graph
                    dpi=100)

How to draw stripplot() graph:

df = sns.load_dataset('attention')
df.head()
graph=sns.boxplot( y=df["score"], x=df["subject"] );
sns.stripplot(y=df["score"], x=df["subject"])

OUTPUT:

Swarplot() graph:

df = sns.load_dataset('exercise')
df.head()
graph=sns.boxplot( y=df["time"], x=df["pulse"] );
sns.swarmplot(y=df['time'], x=df['pulse'])

OUTPUT:




This post first appeared on AR Programming, please read the originial post: here

Share the post

Boxplot in seaborn:

×

Subscribe to Ar Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×