Main Content

Add Legend to Pie Chart

This example shows how to add a legend to a pie chart that displays a description for each slice.

Definexand create a pie chart.

x = [1,2,3]; figure pie(x)

Specify the description for each pie slice in the cell arraylabels. Specify the descriptions in the order that you specified the data inx.

labels = {'Product A','Product B','Product C'};

Display a horizontal legend below the pie chart. Pass the descriptions contained inlabelsto the传说function. Set the legend'sLocationproperty to'southoutside'and itsOrientationproperty to'horizontal'.

传说(labels,'Location','southoutside','Orientation','horizontal')

See Also

|

Related Topics