matlab - Scatter plot with coloured groups and different markers within a group -
i trying make kind of scatter plot different groups. in addition have 2 different markers , 1 color each set of 2 points, connected line. see below details
i have 4 matrices
db = [0.4745 0.3886 0.3316 0.2742; 0.5195 0.3825 0.3341 0.2846; 0.4929 0.3951 0.3161 0.2918; 0.4905 0.4052 0.3240 0.2882]; dw = [0.4814 0.3905 0.3418 0.2922; 0.5258 0.3952 0.3420 0.2974; 0.4945 0.4012 0.3386 0.3001; 0.4885 0.4076 0.3382 0.3056]; sb = [0.0476 0.0527 0.0543 0.0592; 0.0432 0.0503 0.0521 0.0592; 0.0460 0.0531 0.0536 0.0508; 0.0488 0.0520 0.0542 0.0543]; sw = [0.0693 0.0738 0.0785 0.0839; 0.0642 0.0731 0.0763 0.0862; 0.0670 0.0755 0.0807 0.0753; 0.0744 0.0733 0.0792 0.0776];
i plot them scatter plot sb
against db
, sw
against dw
. them have different markers sb
/db
points have 'x' , sw
/dw
points have 'o'.
then additionally want connect them line, example first element of sb
/db
should connected first element of sw
/dw
.
something (edited in graphics editor example...)
i have tried gscatter
gscatter([db(:)' dw(:)'],[sb(:)' sw(:)'],[1:16 1:16])
but don't know how change markers or add lines.
can me this?
you can couple of calls scatter
, 1 call line
.
% turn data 1d row vectors vdb = db(:).'; vdw = dw(:).'; vsb = sb(:).'; vsw = sw(:).'; % plotting figure; hold on % scatters points scatter(vdb, vsb, 'kx'); % plotting black (k) crosses (x) scatter(vdw, vsw, 'ko'); % plotting black (k) circles (o) % line lines! line([vdb; vdw], [vsb; vsw], 'color', 'k') % plot black (k) lines between 'b' , 'w' pts
output:
you can different colours per pair using multiple calls line
instead of using scatter
, specifying markers 2 of calls using start/end points, replacing other nan
.
% no need 'hold on' line doesn't clear plot! figure; line([vdb; nan.*vdw], [vsb; nan.*vsw], 'marker', 'x') % plot coloured x markers line([nan.*vdb; vdw], [nan.*vsb; vsw], 'marker', 'o') % plot coloured o markers line([vdb; vdw], [vsb; vsw]) % plot coloured lines between 'b' , 'w' pts
output:
note uses default colour set. can changed using
set(gca, 'colororder', mycolours)
where mycolours
3 column rgb matrix, seen if use get(gca, 'colororder')
.
Comments
Post a Comment