What is seaborn.boxplot?

A box plot is a widely used method of graphical visualization. It is a key source of depicting quartiles (upper and lower) in individual features. Moreover, one can use it to find outliers in data features. In Python, box plots are mostly used for comparison purposes.

widget

Seaborn makes life easier when creating plots. It is a great and widely used library for the visualization of statistical plots in Python that offers a variety of color palettes and statistical styles to make plots more appealing. Since it is built on top of the matplotlib.pyplot library, it can be easily used and linked with libraries likepandas.

Let’s look at a few visualizations in seaborn python below:

Single box plot

import seaborn as sns
import matplotlib.pyplot as plt
# load dataset from seaborn
df = sns.load_dataset('iris')
df.head()
# y is the data to be plotted on y-axis for vertical boxplot
sns.boxplot( y=df["sepal_width"], width=0.5);
plt.show()

Multiple box plot

import seaborn as sns
import matplotlib.pyplot as plt
# load dataset from seaborn
df = sns.load_dataset('iris')
df.head()
# y is the data to be plotted on y-axis for vertical boxplot
# x is what kinds of values we want boxplot of
sns.boxplot( x=df["species"], y=df["sepal_width"], width=0.5);
plt.show()

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved