How to put labels to a pie chart
3 views (last 30 days)
Show older comments
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?
0 Comments
Answers (2)
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)))
0 Comments
See Also
Categories
Find more on Pie Charts 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!