You can plot them one at a time:
x=[1,2,3,4,5,6,7,8,9];
y=[9,8,7,6,5,4,3,2,1];
height=[0,0,2,3,0,0,2,1,0];
heightDifferences = abs(height - y);
% Find the max height difference.
% This will be put blue. Others will be less blue.
% I.e., on line = black, furthest away = pure blue.
maxHeightDiff = max(heightDifferences(height~=0));
plot(x,y,'ks','markerfacecolor',[0 0 0]);
plot(x,y,'rd-');
grid on;
hold on;
for k = 1 : length(height)
if height(k) ~= 0
theColor = [0,0,heightDifferences(k)/maxHeightDiff];
plot(x(k), height(k), 'o', 'markerfacecolor', theColor,...
'MarkerSize', 15);
end
end
Or you can call scatter() and pass in the colors if you make theColor an array in the above code.