Creating Pie Charts In MatLab®(Illustrated Expression)

1 min reading time..

Pie charts are a very important graph type in statistics and data analyses. They can be a very good illustration of data on around graph. You can create pie charts in Matlab® with the ‘pie()’ command. Here, we will explain how to create pie charts in Matlab®, with a very basic example below.

How To Use ‘pie()’ Command In MatLab®?

Drawing pie charts in Matlab®.

To create pie charts in Matlab®, you need to properly define all the elements of the pie() command in Matlab®. First of all, we need to define the percentages of variables in the pie chart. For example, we created avector that includes populations of different countries in millions as shown by the red arrow above. We calculated the sum of all populations with the ‘sum()’ command, then we divided the population vector with this value to obtain percentages of populations to show a pie chart. We said ‘percentage’ to this vector.

Also, you can directly create a vector that includes percentages for the pie chart.

To show the names of segments in the pie chart, create a string vector that must include the names of each segment coherent with populations. We created it as shown by the red arrow above, which includes country names.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

You can highlight the required variables in a pie chart with the highlight() command. Do this by creating a vector that includes zeros and ones. The dimension of this vector must be the same as other vectors that are used in pie chart generation. One will highlight the respective element in the pie chart. For example, Ecuador and Chile are highlighted because the elements in the ‘highlight’ vector that represents them respectively are ones.

Download And Install Matlab® 2020!

Type percentage, highlight, and string vector into pie() command as shown in the green box above. Then press ‘Enter’ from your keyboard to create a pie chart like above.

Conclusion

Creating pie charts with pie() command is very easy like above in Matlab®. Do not forget to leave your comments and questions about pie charts in Matlab® below. Your precious feedbacks are very important for us.

This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®

Your precious feedbacks are very important to us.

COMMENTS
There are no comments for this article yet! You can make the first comment.
Leave a Comment

x