I have some vectors I am plotting in a scatter plot: x, y, and z.
I plot these vectors using the scatter3 function.
scatter3(x, y, z)
This now provides me with my scatterplot correctly. However, all points are blue, and I need to colour some of the points different colours.
To this end I have a vector 'colours'. Colours is the same length as x, y, and z. Colours is a character array, consisting of the different characters for colours in matlab, such as 'b' for blue, 'r' for red', and so on.
//A small example: colours == 'bbbbbyyyrrr'
I realise I can probably loop through all points and recolor after plotting. However, the simulations produce large vectors, and this is very inefficient with time.
Is there a way to use the colours vector to colour the points such that the point given by x(3), y(3), z(3), would be of colour colours(3)?
scatter3(x,y,z,[],c)wherecis a vector where, for example, 1 corresponds to'b', 2 to'c', etc. then set up a custom colormap for the colours.ccan also be annby 3 matrix of RGB values for each data point. - David