I would like to plot a simple scatter graph in MATLAB, with marker colours varying from one end of the spectrum to the other (e.g. red, orange, yellow....blue, purple).
My data compares the amount of water in a river with the quality of the water, over time (3 simple columns: time, amount, quality). I would like to plot the x,y scatter plot of amount vs quality, but with the colour progressing over time, so that it is possible to see the progression of the quality over time.
I will need to produce many graphs of this type, so if I can find a piece of code that will work for any length of dataset, that would be really useful.
Many thanks in advance for helping a Matlab novice!
You can use the color argument of scatter
If your data are already sorted in time than simply use:
% let n be the number of points you have
cmp = jet(n); % create the color maps changed as in jet color map
scatter(x, y, 10, cmp, 'filled');
Otherwise you need to sort your data first:
[time, idx] = sort(time);
x = x(idx);
y = y(idx);
cmp = jet(n); % create the color maps changed as in jet color map
scatter(x, y, 10, cmp, 'filled');