Well, this is probably too obvious to be the solution to your problem, but in this line:
scatter(x(1:end-1), y(1:end-1),5, lg);
If lg
is the same size as x
and y
, then clearly this is wrong and you need to do:
scatter(x(1:end-1), y(1:end-1),5, lg(1:end-1));
If this does not solve your problem, then as I stated in my comment you must provide complete code that we can run to reproduce the problem, including sample data for the x
, y
, and lg
vectors.