donutchart

Draws a donut chart, a pie chart with a hole in the middle.

Category: Graphics > 2-D and 3-D Plots

Syntax

donutchart(data)

One slice per element of the vector data, sized by its share of the total.

donutchart(data, names)

Labels the slices with names.

d = donutchart(___)

Also returns the DonutChart object.

Description

Each slice spans an angle proportional to its value divided by the sum of all values. The hole leaves room for a title or a total. As with pie charts, differences between similar slices are hard to judge, so a bar chart is often better for exact comparison.

Input arguments

data
Vector of non-negative values.
names
Cell array or string array with one name per slice.

Output arguments

d
The DonutChart object.

Example

Shares of a total

d = donutchart([45 30 25], {'Rent', 'Food', 'Other'});
disp(class(d))
Output
matlab.graphics.chart.DonutChart

See also

pie bar bubblecloud piechart