Plotting graph using Seaborn: Python

Seaborn is a Python data visualization library offers many advanced data visualization capabilities. It comes up with a high-level interface for drawing attractive and explanatory statistical graphics . Its plotting functions operate on Pandas DataFrames and numPy arrays containing whole datasets and internally carry out the necessary semantic mapping and statistical aggregation to produce explanatory plots. The Seaborn library is built on top of Matplotlib and integrates closely with pandas data structures.

Install Seaborn

pip install seaborn
example
import matplotlib.pyplot as plt import seaborn as sns sns.distplot([0, 1, 2, 3, 4, 5]) plt.show()
distplot - A Distplot or distribution plot shows the statistical distribution of data.
seaborn Distplot

Distplot Without the Histogram

import matplotlib.pyplot as plt import seaborn as sns sns.distplot([0, 1, 2, 3, 4, 5], hist=False) plt.show()

seaborn Distplot Without the Histogram

Joint Plot

The jointplot is used to output the mutual distribution of each column.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.jointplot(x='Decor', y='Price', data=dataset)

seaborn jointplot

Pair Plot

The pairplot is a type of distribution plot that basically plots a joint plot for all the possible combination of numeric and Boolean columns in your data.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.pairplot(dataset)

seaborn pairplot

Rug Plot

import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.rugplot(dataset['Price'])
The rugplot is used to draw small bars along x-axis for each point in the dataset.
seaborn rugplot

Bar Plot

A barplot is basically used to aggregate the categorical data according to some methods and by default it's the mean.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.barplot(x='Food', y='Price', data=dataset)

seaborn barplot

Count Plot

The count plot is similar to the bar plot, however it displays the count of the categories in a specific column.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.countplot(x='Food', data=dataset)

seaborn count plot

Box Plot

A box plot helps to maintain the distribution of quantitative data in such a way that it facilitates the comparisons between variables or across levels of a categorical variable.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.boxplot(x='Service', y='Price', data=dataset)

seaborn box plot

Violin plot

Violin plots show the same summary statistics as box plots , but they also include Kernel Density Estimations that represent the shape/distribution of the data.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.violinplot(x='Food', y='Price', data=dataset)

seaborn Violin plots

Strip Plot

A strip plot is a scatter plot where one of the variables is categorical. They can be combined with other plots to provide additional information.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.stripplot(x='Food', y='Price', data=dataset)

seaborn strip plot

Swarm Plot

The swarm plot is a combination of the strip and the violin plots.
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns dataset = pd.read_csv('hotel.csv') sns.swarmplot(x='Food', y='Price', data=dataset)

seaborn swarm plot