Matlab → Graphs → Multiple Graphs → Different Types
So far, all the plots presented here are line graphs. In Matlab, many other type of graphs are easily plotted. For example, consider sale of an item in different years.
Year | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 |
Sale | 40 | 60 | 95 | 80 | 50 | 50 | 70 | 90 |
Vertical bar graph
>> year=[2011:2018];
>> sale=[40 60 95 80 50 50 70 90];
>> bar(year,sale)
Horizontal bar graph
>> year=[2011:2018];
>> sale=[40 60 95 80 50 50 70 90];
>>barh(year,sale)
Stairs graph
>> year=[2011:2018];
>> sale=[40 60 95 80 50 50 70 90];
>> stairs(year,sale)
Stem graph
>> year=[2011:2018];
>> sale=[40 60 95 80 50 50 70 90];
>> stem(year,sale)
The Pie Chart
Pie chart is a beautiful way to visualize relative size of different but related quantities.For example, consider the following data that show the percentage of internet users preferred different web browsers.
Web Browser | Chrome | Firefox | IE | Safari |
Users | 45% | 25% | 10% | 20% |
The pie chart showing this data can be plotted using the Matlab command,
>> users=[45 25 10 20];
>> pie(users)
NOTE: Matlab plots pie chart with different colors for each section. Later, colors can be changed and text could be added using figure properties option in the “Edit” menu of the figure widow. Moreover, font and text sizes can also be changed. More options in the Figure Window should also be explored.