Azzera filtri
Azzera filtri

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 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

DGM
DGM il 3 Apr 2021
Modificato: DGM il 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.

Più risposte (1)

Jan
Jan il 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

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by