I am plotting a grouped scatter plot with different colors. I let Matlab decide the colors, and it uses a flat mapping into the (default?) colormap.
I need to use the same colors as in the scatter-group for the lines.
However, the default ColorOrder
of the lines is not the same as scatter's. Hence, resetting the ColorOrderIndex
does NOT solve the issue.
Currently I can produce the follwing:
with:
% Data
N = 3;
T = 5;
xm = [6.3327 4.5682 6.1398
7.6289 5.4423 10.5246
3.5362 6.2185 8.2151
6.6572 9.4543 7.4266
6.1138 8.6453 8.2044];
ym = [7 0 7
11 0 55
1 1 18
14 6 12
8 2 22];
lm = [6.8176 0.3609 6.9693
13.0347 0.5587 62.4217
1.6841 0.8237 19.6712
8.0186 4.1533 13.2623
6.1108 2.7716 19.5666]
% Scatter groups
g = kron((1:N)',ones(T,1)); %// '
hs = scatter(xm(:),ym(:),[],g,'filled');
hold on
% Poisson group-fits
[xmsorted,posxm] = sort(xm);
posxm = bsxfun(@plus, (0:N-1)*T, posxm);
hl = plot(xmsorted,lm(posxm));
I tried to get the CDATA
from the scatter, and it's basically my g
(group index), and used that to index directly into the default colormap, but it seems that scatters use a different colormap?