Matlab – How to change the axes labels on a boxplot


When using the boxplot command from Statistics toolbox, the axes properties change in a strange way. For example, one gets

    XTick = []
    XTickLabel = 
    XTickLabelMode = manual
    XTickMode = manual

What is happening to the axes and how one can rename the labels, and/or drop some of the ticks?

Best Solution

Try calling boxplot using the optional labels parameter.

Edit - further information about what boxplot actually does.

boxplot does some complicated stuff - type edit boxplot to take a look through the code, and you'll see it's a very long and intricate function. Basically it makes a blank axis with no axis labels, which is why you're seeing empty values for XTick etc. Then it makes the boxplot elements out of individual lines, and it simulates fake axis labels by adding text elements. You can find them and modify them directly by plotting into a figure f, then getting the Children of f, then iterating through to get their Children. Eventually you'll find text elements with the label names.

Related Question