How to put labels to a pie chart

3 views (last 30 days)
Kristina
Kristina on 15 Oct 2014
Answered: Star Strider on 15 Oct 2014
I have a matrix X. In the first column there are 5 values which are integers from 0 to 4. In the second column there are values that I want to plot in a pie chart. How can I label the values in X(:,2) with the corresponding values from X(:,1) in the pie chart?

Answers (2)

the cyclist
the cyclist on 15 Oct 2014
Did you try reading the documenation? Type
doc pie
or look here.

Star Strider
Star Strider on 15 Oct 2014
One way:
X = [0:4; randi(100,1,5)]'; % Create Data
Lbls = strsplit(sprintf('%d ',X(:,1)));
figure(1)
pie(X(:,2), Lbls(1:size(X,1)))

Community Treasure Hunt

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

Start Hunting!