How to set different colors for branches when making 3d tree structure plotting from excel columns?

Hi everyone,
I have excell file and I want to create 3dimensional tree structure2 with colors.
This is my excell file and following code reads and plot3 successfully.
branchName = xlsread('data.xlsx', 'A:A');
coordinates = xlsread(data.xlsx', 'B:D');
x = coordinates(:,1);
y = coordinates(:,2);
z = coordinates(:,3);
data=[branchName,x,y,z];
plot3(x,y,z);
What I need to do is I want to color the branches and put name on it. For example plot needs to be seen like following.
I tried patch but it did not helped.
patch(x,y,z,'EdgeColor','interp','Marker','none','MarkerFaceColor','flat');
Thank you.

Answers (1)

You need to use plot3 with the segments by mentining different colors. You need to use hold on. To name the segments, use text.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!