piechart
Pie chart object with names, labels and a title, from a vector or a table.
Category: Graphics > 2-D and 3-D Plots
Syntax
piechart(data)
Draws one slice per element of the numeric vector data.
piechart(data, names)
Names the slices with names.
piechart(tbl, dataVar, namesVar)
Uses variables of a table for the values and the names.
piechart(___, Name, Value)
Sets chart properties such as 'Title'.
p = piechart(___)
Also returns the PieChart object.
Description
piechart is the chart-object counterpart of pie. Instead of low-level graphics objects it returns one object whose properties you set, and it shows the names and percentages next to the slices. It also provides a legend and groups very small slices if you ask for it.
Input arguments
data- Numeric vector of non-negative values. Repeated names are combined.
names- Cell array or string array of slice names.
Output arguments
p- PieChart object. Its properties control labels, colors and the title.
Example
Named slices
data = [35 25 20 20];
names = {'Rent', 'Food', 'Transport', 'Other'};
p = piechart(data, names);
p.Title = 'Monthly budget';
In the app, the chart is drawn below the code.