Emil
Emil

Reputation: 13

Put labels to a pie chart

I have a 10x2 matrix A. In the first column there is values between 65 and 90 that can be converted to letters using the char(X) command. In the second column there is values that I want to plot in a pie chart. How can I label the values in A(:,2) with the corresponding letters from A(:,1) in the pie chart.

Upvotes: 1

Views: 3269

Answers (1)

Ghaul
Ghaul

Reputation: 3330

The pie() function does the labeling job for you if you feed it the right kind of input string. The problem is that it wants the input string in cell form. That means that you have to use cellstr() after you use the char() command.

Like this:

pie(A(:,2),cellstr(char(A(:,1))))

Upvotes: 2

Related Questions