Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Pie chart

`pie(X)`

`pie(X,explode)`

`pie(X,labels)`

`pie(X,explode,labels)`

`pie(ax,___)`

`p = pie(___)`

`pie(`

draws a pie
chart using the data in `X`

)`X`

. Each slice of the pie
chart represents an element in `X`

.

If

`sum(X) ≤ 1`

, then the values in`X`

directly specify the areas of the pie slices.`pie`

draws only a partial pie if`sum(X) < 1`

.If

`sum(X) > 1`

, then`pie`

normalizes the values by`X/sum(X)`

to determine the area of each slice of the pie.If

`X`

is of data type`categorical`

, the slices correspond to categories. The area of each slice is the number of elements in the category divided by the number of elements in`X`

.

`pie(`

offsets
slices from the pie. `X`

,`explode`

)`explode`

is a vector or matrix
of zeros and nonzeros that correspond to `X`

. The `pie`

function
offsets slices for the nonzero elements only in `explode`

.

If `X`

is of data type `categorical`

,
then `explode`

can be a vector of zeros and nonzeros
corresponding to categories, or a cell array of the names of categories
to offset.