1

I am looking for a function to create a so called Beeswarm boxplot. This is very popular plots used in medicine and biology and I was surprised not to find it for MATLAB.

Basically the numerical data for each group are splitted to bins and jitter of points depends on number of points in a particular bin.

Here is an example done with R using BEESWARM function:

beeswarm example

Different colors for additional group is very nice feature but it not needed for me now.

asked Mar 19, 2012 at 20:39
0

1 Answer 1

3

There is a function on the file exchange called plotSpread that can do these plots:

plotSpread({rand(100,1),randn(100,1)})

enter image description here

 data = [randn(50,1);randn(50,1)+3.5]*[1 1];
 catIdx = [ones(50,1);zeros(50,1);randi([0,1],[100,1])];
 plotSpread(data,'categoryIdx',catIdx,...
 'categoryMarkers',{'o','+'},'categoryColors',{'r','b'})

enter image description here

answered Mar 19, 2012 at 23:47
5
  • Thanks a lot, @Jonas. I'm using distributionPlot a lot, but somehow missed this function existence. It's perfectly fit my current needs. Consider including a spread plot as an example on FE. Also it would be nice if the function could return handles for mean-median. Commented Mar 20, 2012 at 15:31
  • @yuk: I had debated as to whether I should put it as a separate entry on FE; but maybe it would make sense. There's a bunch of features I've added for distributionPlot that I could copy over to plotSpread, and I'd rather do one big overhaul than many small ones, so what other features would you like in plotSpread? Commented Mar 20, 2012 at 16:39
  • I think it could be a great separate submission on FE. And once you ask for other features here are some: (1) output like in distributionPlot, (2) grouping (boxplot like), (3) color groups, (4) hor/vert orientation, (5) input arguments as name/value pairs, (6) if possible different methods as in R/beeswarm. Commented Mar 20, 2012 at 18:23
  • @yuk: An independent version of plotSpread has been uploaded. It contains features 1,2,3,4,5, and 6-ish, though I use slightly different methods. Commented Jun 11, 2012 at 20:07
  • Thank you, @Jonas. Sorry, I was not able to test it as promised. In rush at work. Commented Jun 12, 2012 at 3:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.