I have this matrix that is ready to be plotted in "Matlab" with scatter3
, if the following command is used
scatter3( F(:,[1]) , F(:,[2]) , F(:,[3]) , F(:,[4]) , F(:,[5]) )
(I am basically splitting the F matrix in 5 column vectors)
F =
52.5000 12.6000 288.0000 20.0000 1.0000
52.5000 6.3000 408.0000 20.0000 1.0000
52.5000 4.8000 467.0000 20.0000 1.0000
52.5000 3.5000 559.0000 20.0000 1.0000
52.5000 2.0000 730.0000 20.0000 1.0000
52.5000 1.3000 902.0000 20.0000 1.0000
26.2500 12.6000 203.0000 20.0000 2.0000
26.2500 6.3000 288.0000 20.0000 2.0000
26.2500 4.8000 332.0000 20.0000 2.0000
26.2500 3.5000 389.0000 20.0000 2.0000
26.2500 2.0000 516.0000 20.0000 2.0000
26.2500 1.3000 637.0000 20.0000 2.0000
10.0000 12.6000 125.0000 20.0000 3.0000
10.0000 6.3000 177.0000 20.0000 3.0000
10.0000 4.8000 204.0000 20.0000 3.0000
10.0000 3.5000 240.0000 20.0000 3.0000
10.0000 2.0000 318.0000 20.0000 3.0000
10.0000 1.3000 392.0000 20.0000 3.0000
5.0000 12.6000 88.0000 20.0000 4.0000
5.0000 6.3000 125.0000 20.0000 4.0000
5.0000 4.8000 144.0000 20.0000 4.0000
5.0000 3.5000 169.0000 20.0000 4.0000
5.0000 2.0000 224.0000 20.0000 4.0000
5.0000 1.3000 277.0000 20.0000 4.0000
2.0000 12.6000 55.0000 20.0000 5.0000
2.0000 6.3000 78.0000 20.0000 5.0000
2.0000 4.8000 90.0000 20.0000 5.0000
2.0000 3.5000 106.0000 20.0000 5.0000
2.0000 2.0000 141.0000 20.0000 5.0000
2.0000 1.3000 175.0000 20.0000 5.0000
1.0000 6.3000 55.0000 20.0000 6.0000
1.0000 4.8000 63.0000 20.0000 6.0000
1.0000 3.5000 75.0000 20.0000 6.0000
1.0000 2.0000 99.0000 20.0000 6.0000
1.0000 1.3000 123.0000 20.0000 6.0000
0.5000 6.3000 38.0000 20.0000 7.0000
0.5000 4.8000 44.0000 20.0000 7.0000
0.5000 3.5000 52.0000 20.0000 7.0000
0.5000 2.0000 70.0000 20.0000 7.0000
0.5000 1.3000 86.0000 20.0000 7.0000
If you plot this you'll see that the points are grouped in 7 same coloured groups (taken from column 5 of the F matrix).
I would like to plot lines connecting the same coloured points. Of course the lines should have the same colour as the points they connect.
I have attempted to split the F matrix in five 6x5 matrices (named F1-F5) and 2 5x5 matrices (named F6 and F7) and use scatter3()
along with line()
commands and hold on
to create my 3D graph, but it did not do what I wanted.
For every new set of points that is plotted with scatter3()
the sets of points already plotted change colour. So assigning a short name colour in the line()
function does not help.
What options do I have? Perhaps scatter3
is not the best function to use in this case?
EDIT
plot3()
is promising , but has a limited color set. Indeed I would prefer to avoid using colours "white" and "yellow", which do not show up nice on white background.
So, I will assume you are going to separate your matrices into 7, in this case, and save them in a cell array, as dynamic variables are BAD!
Assuming you have a cell array called F
this works:
C=hsv(7);
hold on
for ii=1:size(F,2)
% //plot lines
plot3(F{ii}(:,1),F{ii}(:,2),F{ii}(:,3),'Color',C(ii,:));
% // plot points
plot3(F{ii}(:,1),F{ii}(:,2),F{ii}(:,3),'.','MarkerSize',F{ii}(1,4),'Color',C(ii,:));
end
The only problem it has is that it doesnt allow for multiple marker sizes, so if you want the points to have different marker sizes, you'd need to add another loop and go plotting the points one by one. I hope you are able to get it from here ;)