
The box plot is great for multi-layered comparison. It allows you to compare across two categories. Here we simply compare one varialble across different levels. For example, you could compare income across decades or across selected countries. In such a case, the variable needs to be measured in the exact same way for each level. But, you are not limited to comparing the same variable across levels, it could be different variables; as long as the comparison is justifiable. The plot contains as many boxes as there are variables.

You can incorportate a second level of comparison by using the by() command. Remember that you will get as many plots as there are levels in your categorical variable. You also need to include any command that is common to all plots, such as the overal title. Remember to close the parenthesis before adding plot specific commands!

To label each box, use the command ascategory yvaroptions( relabel(1 "label1" 2"label2")), where the number corresponds to a box (1 is the left most box). Then, you can add a label for that specific box.

The final part includes the usual set of commands to improve clarity and accuracy.

As with the comparative histograms we can add individual title for each plot by using label. Remember, you need to plot again after defining the labels.