Creating box plots with notches

In this recipe, we will learn how to make box plots with notches, which are useful in comparing the medians of different groups.

We will continue to use the metals.csv example dataset for this recipe. So, let's first load it:

We shall now see how to make a box plot with notches:

How to do it...

In the example, we set the notch argument to TRUE to create notches on each side of the boxes. If the notches of two plots do not overlap, then the medians are significantly different at the 5-percent level, which suggests that the median concentrations at the four sites as shown are not statistically different from each other.

We can set the notch.frac argument to a value between 0 and 1 to adjust the fraction of the box width that the notches should use. The default value is 0.5 and a value of 1 gives notches using the entire width of the box, effectively producing a box plot without notches.