categorical scatter plot change colors of points within group

5 views (last 30 days)
Hello,
I'm attempting to create a categorical scatter plot with individual RGB color codes assigned to individual points. In addition, I would love to have different marker shapes applied to each category. I am currently using UnivarScatter https://www.mathworks.com/matlabcentral/fileexchange/54243-univarscatter from the file exchange and cannot figure out how to make this happen; this code treats each category as a group and I cannot change colors of individual points even when I go into figure properties. Does anyone know a way around this or another categorical scatter plot that allows me to assign RGB codes by row?
Thank you!
  4 Comments
Manuel Lera Ramírez
Manuel Lera Ramírez on 16 Aug 2018
Hello Emily. I replied to your question in the forum of the function.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
hold on
% Draw coloured points on top of the plot
scatter(x(:,1),y(:,1),[],my_rgb,'filled')
Hope its helpful
Walter Roberson
Walter Roberson on 16 Aug 2018
If the color is not intended to be consistent per category, that what is intended to be graphically consistent per category but different from category to category? Marker shape? Font size? Transparency? Z coordinate? Marker size? Marker edge color?

Sign in to comment.

Answers (0)

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!