Every 1,5,9,13..... marker point should be of same color. Similarly 2,6,10...... and 3,7,11...... and 4,9,12.... should be of same color

2 views (last 30 days)
As shown in the plot below. I need the marker color of [1,5,9,13........] of same color. Similarly [2,6,10,.....] for e.g., green; [3,7,11......] for e.g blue; [4,9,12...] for e.g. magenta.
Thanks ,
Aristo

Accepted Answer

DGM
DGM on 3 Apr 2021
Edited: DGM on 3 Apr 2021
Try something like this:
len = 1000; % dataset length
x = linspace(0,10,len);
y = exp(x/10).*sin(4*x);
colors=[1 0 0; ...
0 1 0; ...
0 0 1; ...
1 1 0];
clf;
plot(x,y); hold on;
ncolors=size(colors,1);
for p=1:ncolors
plot(x,y,'o','MarkerSize',8,...
'MarkerEdgeColor','red',...
'MarkerFaceColor',colors(p,:),...
'MarkerIndices',p:ncolors:len)
end
This requires a relatively recent version. I'm not sure of the exact version, but the 'markerindices' property isn't a thing in R2015b at least.

More Answers (1)

Jan
Jan on 3 Apr 2021
x = 1:100;
y = rand(1, 100);
colorPool = [1,0,0; 0,1,0; 0,0,1; 1,0,1];
figure;
axes('NextPlot', 'add'); % Equivalently to: hold('on')
plot(x, y, 'b-');
for k = 1:4
ind = k:4:100;
plot(x(ind), y(ind), 'o', 'MarkerEdgeColor', colorPool(k, :));
end

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!