Can matlab figure have vertical separator line?

Viewed 64

I am trying to achieve a similar graph to the one shown below. I have been researching how to add lines as separators and put 2 box plots in between 2 lines. The dataset I have is that I have 3 message sizes of type A and 3 same message sizes of type B. I want to draw them side by side based on their sizes. Below is the similar graph that I want to achieve. There are 2 box plots in each column which represent they are the same message size, only different type.

Final result

What keyword should I search for that result?

1 Answers

What you want can be achieved defining two grouping variables for the data, and using the 'factorseparator' input of boxplot to specify which grouping variable should generate separators (vertical lines):

X = rand(30, 8); % example data matrix. Each column generates a box
g_sizes = {'16k' '16k' '32k' '32k' '64k' '64k' '128k' '128k'}; % message sizes
g_types = {'A' 'B' 'A' 'B' 'A' 'B' 'A' 'B'}; % messsage types
boxplot(X, {g_sizes g_types}, 'factorseparator', 1) % 1st variable geneates separators

enter image description here

Related