This example shows how to add a legend to a pie chart that displays a description for each slice.
Define x
and create a pie chart.
x = [1,2,3]; figure pie(x)
Specify the description for each pie slice in the cell array labels
. Specify the descriptions in the order that you specified the data in x
.
labels = {'Product A','Product B','Product C'};
Display a horizontal legend below the pie chart. Pass the descriptions contained in labels
to the legend
function. Set the legend's Location
property to 'southoutside'
and its Orientation
property to 'horizontal'
.
legend(labels,'Location','southoutside','Orientation','horizontal')