Code covered by the BSD License  

Highlights from
plot spread points (beeswarm plot)

5.0

5.0 | 2 ratings Rate this file 73 Downloads (last 30 days) File Size: 13.2 KB File ID: #37105
image thumbnail

plot spread points (beeswarm plot)

by

 

11 Jun 2012 (Updated )

plotSpread plots distributions of data points, adding jitter to the points to avoid overlap.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

plotSpread allows creating "beeswarm plots", i.e. point distributions where jitter has been added to the data points to avoid overlap.

It further allows specifying groups within the data to show the distribution of the groups inside a distribution.

plotSpread is most suited to visualizing distributions with small amounts of data points. If the points become too dense, it becomes difficult to appreciate the relative importance of modes of a distribution, in which case "distributionPlot" should be used.

plotSpread uses the excellent "distinguishable_colors" to choose default colors for different categories.

In addition, the .zip file contains "myErrorbar" (a modification of the built-in errorbar), "repeatEntries" for easy repetition of entries in a list, and "isEven" to test whether a number is even. For both "repeatEntries" and "isEven" there are better alternatives on the File Exchange.

Acknowledgements

Generate Maximally Perceptually Distinct Colors inspired this file.

This file inspired Violin Plots For Plotting Multiple Distributions (Distribution Plot.M).

Required Products MATLAB
MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
23 Oct 2012 Jonas

@Yuri: Thank you for the hint. I'll look into fixing this.

22 Oct 2012 Yuri K

I found that distinguishable_colors function requires makecform function from Image Processing Toolbox. Not every installation has it.

11 Oct 2012 Jonas

To change marker size programmatically, you can use the function "findall" to get the handles for the spots. Say you want to set the marker size to 16 of the black markers, and the figure number is 3, you could write
set(findall(3,'type','line','color','k'),'markerSize',16)

09 Oct 2012 Ana

Hi,

Thanks for the script!!Is really useful but can you tell me how I change the marker size in your script?

Thanks

07 Jul 2012 Shatrughan

Hi,

Good script !! Can you implement plotting the mean, median, errorbar, or others with categoryIdx? if yes, how?

Thanks

13 Jun 2012 peter

It works now !!!
Thanks a lot.

12 Jun 2012 Jonas

@peter: "ismatrix" only appeared in 2010b. I've tried and failed to install 2009b today, so I wasn't able to make sure that I haven't included another incompatible function call. Have you been able to test the new version?

12 Jun 2012 peter

I am actually running 2010a, but I still do not have it ?

11 Jun 2012 Jonas

ismatrix is a built-in function from a release later than R2009b - sorry for the mis-labeling of plotSpread. I am replacing ismatrx and I'll upload a fixed version soon

11 Jun 2012 peter

I tested your example and got the following:
I think you forgot to include "ismatrix" function ?
---------------------------------------
??? Undefined function or method 'ismatrix' for input arguments of type
'double'.

Error in ==> plotSpread at 196
elseif ismatrix(data)

Updates
12 Jun 2012

Replaced the call to ismatrix, which is a function that only appeared in MATLAB after R2009b

Contact us