Clear Filters
Clear Filters

Set specific Marker Edge and Face Colour for gscatter group of points

5 views (last 30 days)
I want to colour edge and face of marker point on the base of values in g.
But there are 2 problems:
  • I do not know a-priori how many groups of points (elements in g with different values) I have.
  • I want each specific group has a specific couple of marker face colour and marker edge colour that I define. For example if g(10)=3.5 i need to set marker face colour [1 1 1] and marker edge colour [0 0.6 0.8].
If I had the possibility to relate each h(i) Line Objects to the corresponding g(j) value I could set exactly the colors with commands:
h(i).MarkerEdgeColor=[ colour related to g(j) ];
h(i).MarkerFaceColor=[ colour related to g(j) ];
Example in the attached file
Thanks
  1 Comment
Bruno Martinico
Bruno Martinico on 3 Nov 2020
Wondeful I resolved with this loop on I values (values in accordance with which I define RGB triplets), but not without SS benediction, because hgscat create by default gscatter objects sorted in ascending order regardless of the order of M_Pts(:,i) group markers (numbers).
fMarkFaceCol(I) and fMarkEdgeCol(I) give me the triplet RGB according to the I values
hgscat=gscatter(M_Pts(:,2),M_Pts(:,1),M_Pts(:,i),[],'o',[],'on');
k=1;
for I=1:0.5:11
if k<=length(hgscat)
if ismember(I,M_Pts(:,i))
hgscat(k).MarkerFaceColor=fMarkFaceCol(I);
hgscat(k).MarkerEdgeColor=fMarkEdgeCol(I);
k=k+1;
end
end
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!