Draw an Univariate Scatter plot out of a nx2 table with a
categorical/string and a numerical variable, or out of a
numerical array, with groups/categories corresponding
to the columns of the numerical array.
This kind of graph is very popular in biochemistry/biology
Many custom options are available as Name,Value
pairs. For optimal visualization of your data I
recommend to play with 'RangeCut', and also with pbaspect of the plot, it
really changes the appearance.
You need the following functions for this function to work:
+CatTable2Array: included in the file
Also, a very simple function to assign colors is
provided, ColorCoder, you can see several examples in the
Please, all your feedback is welcome to improve this function
If you use this function in a public webpage or publication, I encourage you to share the reference with me so that I include it in the publications section.
version: <1.2> from 20/03/2020
% Manuel Lera Ramírez: firstname.lastname@example.org
% Developed during Master Thesis Internship in Marcos González-Gaitán's Lab
% Departments of Biochemistry and Molecular Biology, Sciences II,
% 30 Quai Ernest-Ansermet, CH-1211 Geneva 4, Switzerland
Looking at the posts I found a function that does something very similar to this, plotSpread http://www.mathworks.com/matlabcentral/fileexchange/37105-plot-spread-points--beeswarm-plot-
Look for the one that suits better your needs, the final appearance should be different for each case.
The idea of representing std and SEM as rectangles was inspired by the function notBoxPlot by Rob Campbell
Manuel Lera Ramírez (2021). UnivarScatter (https://github.com/manulera/UnivarScatter), GitHub. Retrieved .
Works great, thank you!
Wonderful, works seamlessly, thank you!
Thanks a lot! Really what I needed
Hello Emily. I dont know what you mean exactly by "by row", but if you have a look at the example, you can see that the function outputs the x and y coordinates of the dots on each group.
If I correctly understand what you mean, this could do the trick:
% Some random data
a = rand(5,1);
b = rand(5,1);
data = [a,b];
% Some rgb assigned to each row
my_rgb = [1 0 0; 0 0 1; 0 1 0; 1 1 0; 0 0 1];
% Draw the plot
[x,y] = UnivarScatter(data);
% Put hold
% Draw coloured points on top of the plot
Thank you for the code. I am attempting to assign different RGB values to individual points within the same group. I would like to assign the colors by row. Is this possible?
The comment of last submission (below) (v. 1.1) does not affect the plotting of the confidence intervals, it just affects the grouping of data in bins for plotting groups that have similar values.
As pointed out by Tommy Kaplan, the function was previously calculating the 90% CI of the mean (from 0.05 to 0.95), changed line 469 in UnivarScatter.m to (0.025 to 0.975) to really get the 95% CI. Many thanks to him and sorry for the inconvenience.
My bad, the function perfectly takes care of it (my last comment).
Great function. Wondering how this can be utilized for two groups with different samples. For example, a group with 10 samples vs another with 5 samples.
This code is useful, highly configurable and generates nice plots.
I was looking for this code for months! Very useful thanks
I'm very pleased with the plots I was able to generate using this code. Thanks for the helpful examples too!
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!