pie

pie(x,options) plots a pie chart where the slices are defined by each element of x.

Single vector input

x = [4 2 6 5 1]
pie(x)

Data grouped by category

options = struct     

% initializing options struct

options.categorical = true x = [1 1 2 3 4 1 2 6 5 5]; pie(x,options)

Number of slices defined

options = struct     

% initializing options struct

options.title = 'pieChart' options.categorical = true x = randn(1000,1); pie(x, 10, options)

Edges of slices defined

options = struct     

% initializing options struct

options.categorical = true options.colors = {'#cce6ff','#80bfff','#1a8cff','#0059b3','#003366','#000000'} x = [1 1 2 3 4 1 2 6 5]; pie(x, [1 3 4 6],options)

Labels defined

options = struct     

% initializing options struct

options.legendLabels = {'yes', 'no', 'absent'} options.colors = {'#e6f2ff','#1a8cff','#00264d'} options.categorical = true x = [1 0 1 0 0 0 1 2 0 1]; pie(x, options)

Moved slices

options = struct     

% initializing options struct

options.colors = {'#e6f2ff','#80bfff','#1a8cff','#0059b3','#00264d'} options.categorical = true options.explode = [0,0,1,0,1] x = poissrnd(4, 300, 1) pie(x, 5, options)

Related documentation

Basic Options and Setup - Legend

See also

bar | histogram | waterfall