How to set different colors for branches when making 3d tree structure plotting from excel columns?
Show older comments
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)
KSSV
on 4 May 2021
0 votes
You need to use plot3 with the segments by mentining different colors. You need to use hold on. To name the segments, use text.
1 Comment
OMER FEYZULLAHOGLU
on 4 May 2021
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!