Grouped scatter plot withe symbols and color defined colors and shapes (for loop?)

3 views (last 30 days)
Hi,
I want to create a grouped scatter plot, which is grouped by color, and further subgrouped by symbols, i.e. every color-group is subdived by different symboles. In the end I want one scatter plot with e.g. blue circles & plus & crosses, red cirles & plus & crosses, etc...
X has the data for the x-axis Y has the data for the y-axis C defines the color of each XY pair (e.g. from 1 to 4, where 1=blue, 2=red, 3=green, 4=black) S defines the shape of each XY pair (e.g. from 1 to 3, where 1=circle, 2=plus, 3=cross)
So far, I managed to group the scatterplat using gscatter(x,y,c), which works. I was given the hint to use a for-loop to change the symbol shape according to S, but have no idea how to do that.
Any suggestions?
Thank you!

Answers (1)

Star Strider
Star Strider on 17 May 2014
I don’t know if this is what you are asking for, but it may be part of the solution:
Mrkr = '+o*.xsd^v><ph';
C = colormap(jet(length(Mrkr)));
for k1 = 1:13
XData(:,k1) = 2*k1+k1*randn(10,1);
end
YData = randi(25,10,13);
figure(1)
hold on
for k1 = 1:13
scatter(XData(:,k1), YData(:,k1), 15, 'Marker',Mrkr(k1), 'MarkerFaceColor', C(k1,:))
end
hold off

Community Treasure Hunt

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

Start Hunting!