Hi,
To selectively plot specific groups using 'gscatter' without losing the order of data or plotting unwanted groups like, we can filter the data before plotting it. Here is an example code which demonstrates the above approach:
% Example data
A = rand(10, 1);
B = rand(10, 1);
C = {'Group1', 'Group2', 'Nothing', 'Group1', 'Group3', 'Nothing', 'Group2', 'Group1', 'Group3', 'Nothing'};
% Specify groups you want to plot
groupsToPlot = {'Group1', 'Group2', 'Group3'};
% Create a logical index for the groups you want to plot
isGroupToPlot = ismember(C, groupsToPlot);
% Filter A, B, and C based on the logical index
A_filtered = A(isGroupToPlot);
B_filtered = B(isGroupToPlot);
C_filtered = C(isGroupToPlot);
% Plot using gscatter
figure();
p1 = gscatter(A_filtered, B_filtered, C_filtered);
% Customize plot (optional)
xlabel('A');
ylabel('B');
title('Selective Group Plot');
legend(groupsToPlot);
Kindly, refer to the following documentation for more information on the 'ismember' function: https://www.mathworks.com/help/matlab/ref/double.ismember.html
I hope this helps!