Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Hierarchically grouped boxplot

4.8 | 4 ratings Rate this file 13 Downloads (last 30 days) File Size: 3.26 KB File ID: #40878 Version: 1.1
image thumbnail

Hierarchically grouped boxplot


Matt Tearle (view profile)


22 Mar 2013 (Updated )

A modification to boxplot that shows the hierarchical relationships between the grouping variables.

| Watch this File

File Information

HIERARCHICALBOXPLOT(X,GRP) creates a boxplot of the data in X, grouped according to the grouping variables represented by the columns of GRP. The groupings are shown hierarchically, with the groups in each column of GRP being shown as groups within the groups of the next column.

Known limitation: BOXPLOT readjusts the label positions whenever the figure is resized (including docking/undocking). HIERARCHICALBOXPLOT does *not*. Too much resizing may cause strange-looking label positions.


This file inspired Alternative Box Plot.

Required Products Statistics and Machine Learning Toolbox
MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
19 Feb 2015 Matt Tearle

Matt Tearle (view profile)

Hi Juan (& Arnold -- sorry, for some reason I never saw your comments before)

Thanks for your feedback. Unfortunately there's no easy way to change things because, to be blunt, my code is a pile of pretty hideous hacks on top of boxplot. You could certainly hack my hacks for a specific purpose, but I don't know if there's a good way to do so generally.

I like the idea of using color. Do you have an idea of what the function interface would look like for using color instead of separator lines? I'm wondering about an optional cell array of n strings (n = number of grouping variables) that could be something like 'color', 'backgroundcolor', 'line', or 'none'. But that way you couldn't specify *what* the colors were, unless you could give another array of colors. But that seems a bit tedious. Any thoughts?

Comment only

Hi Matt,

Thank you for this code. I wonder if you could give me a hand with this. First, I would like to use background color instead of lines for separating my groups. Second, I would like to substract the first line of ticks. Let me try to be clearer with this part. Taking the plot you have as an example, I would like to substract "70 76 82 70 76 82 70 76 82" just from the ticks.

I really appreciate your help.


Comment only
12 Feb 2015 JUAN DAVID PEREZ  
28 Jul 2014 arnold

arnold (view profile)

Hi Matt, I was wondering if you might have a chance to include coloring+legend as another dimension. Otherwise... using it every week. Regards Arnold

Comment only
26 Jan 2014 arnold

arnold (view profile)

Hi Matt,
thanks for the function. This is really missing in Matlab.
A couple of thoughts that might make it even better:

The ability to plot the lowest hierarchy/dimension as different box-color, or maybe second y-axis. This is closely related to the second idea:
The ability to plot 2-y axis, differentiated by color as well. Many applications have two different variables you might wanna show.

3. It would be more usable if one could simply feed it a table. The new 'table' data type looks like it would for great with this.

18 Oct 2013 Eric Sampson  
26 Apr 2013 DAEJIN

DAEJIN (view profile)

25 Mar 2013 1.1

Copyright info

Contact us