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

1 回表示 (過去 30 日間)
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

採用された回答

DGM
DGM 2021 年 4 月 3 日
編集済み: DGM 2021 年 4 月 3 日
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.

その他の回答 (1 件)

Jan
Jan 2021 年 4 月 3 日
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

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by