MATLAB: Colour Code Points Based on (x,y) Coordinates

colormap

Hello
Below is an example where I have used the (x,y) coordniates to produce a truecolor [R,G,B] values along each axis and then each point is plotted and colour coded.
x = rand(100,1); y = rand(100,1);
xyColour = [x zeros(size(x)) 1-x] + [1-y 1-y y];
figure(1)
scatter(x,y,20,xyColour,'filled');
xlabel('x'); ylabel('y');
grid on
axis square
xlim([-0.1 1.1]);
ylim([-0.1 1.1]);
If you run this code you will get something like this:
You can see that the colours go from blue in one corner through to bright yellow in the other corner and fade to almost white at the bottom.
While this sort of does what I want, I envisaged having stronger variation across the plot (e.g. bright red moving to bright green and then to bright blue) to make interpretation of the points easier. The reason I want to do this is because the points here represent the result of a measurement. In my case x and y are actually principal components of 522 measurements take across a sample and I wanted to colour code an image of the sample to show where the measurement taken at different positions lie in PC space. The variation in colour is too 'weak' and it can make interpretation difficult.
If anyone can think of a better way to do this so that the colour transition gradient is increased across the plot I would be grateful.
Many thanks

Best Answer

hsvColour = [x * 0.9, y, ones(100,1)];
xyColour = hsv2rgb( hsvColour );
Or some variation on the theme maybe gives a brighter variation. I multiplied by 0.9 for Hue just as a quick and dirty way to avoid having red appear at both sides of the x axis as it would with the full circular hue range.