O'Reilly logo

MATLAB Graphics and Data Visualization Cookbook by Swapnonil Banerjee, Nivedita Majumdar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pie charts, stem plots, and stairs plots

In this recipe, you will see the popular chart types: pie charts, stem plots, and stairs plots.

How to do it...

Perform the following steps:

  1. Pie charts are created with the MATLAB command pie. Plot a pie chart and explode a slice out of the pie, for added emphasis:
    Expenses = [20 10 40 12 20 19 5 15]; ExpenseCategories = {'Food','Medical','Lodging','Incidentals','Transport',... 'Utilities','Gifts','Shopping'}; MostLeastExpensive = ... (Expenses==max(Expenses)|Expenses==min(Expenses)); h=pie(gca,Expenses,MostLeastExpensive,ExpenseCategories); % Every alternate handle returned by pie is a text object. Use % that to increment the font size of the labels for i =2:2:16;set(h(i),'fontsize',14);end % Add annotation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required