The box in the box plot displays the dataset’s median, first and third quartile, and the interquartile range. The line in the center of the box shows the median, the edges shows the first and third quartiles, and the interquartile range is visualized by the width of the box.
The two datasets can be analyzed visually by placing two box plots side by side. This allows easy comparison of median, first and third quartiles and the IQR of the datasets.
In Python’s Matplotlib library, if multiple datasets are specified in function
pyplot.boxplot(), then those datasets will be visualized as side by side box plots.
mul_datasets = [[3, 5, 7, 2], [2, 4, 10, 43]]pyplot.boxplot(mul_datasets)
In a box plot, the data points that fall beyond the whiskers are called outliers. They are usually labeled with a dot or an asterisk.
A box plot’s whiskers are the lines that extends from the 1st or 3rd quartile to points farthest from the median. The upper whisker of the box plot is the largest dataset number smaller than 1.5IQR above the third quartile and the lower whisker is the smallest dataset number larger than 1.5IQR below the first quartile.
In Python’s Matplotlib library, the
pyplot.boxplot() function takes a dataset as input and returns a box plot.
# dataset= list of numberspyplot.boxplot(dataset)