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.
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:
import seaborn as snsimport matplotlib.pyplot as plt# load dataset from seaborndf = sns.load_dataset('iris')df.head()# y is the data to be plotted on y-axis for vertical boxplotsns.boxplot( y=df["sepal_width"], width=0.5);plt.show()
import seaborn as snsimport matplotlib.pyplot as plt# load dataset from seaborndf = 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 ofsns.boxplot( x=df["species"], y=df["sepal_width"], width=0.5);plt.show()
Free Resources