Mark As Completed Discussion

Pie Chart

A pie chart is a circular graph that is divided into segments or slices of pie (Like a Pizza). It is used to represent the percentage or proportional data where each slice of the pie represents a category. This is very similar to Bar chart, but in a circular fashion.

When there is an order defined in the labels, or there are too many labels then we will use Bar charts. And when the label does not have any order, we can use Pie Charts.

We will use Pie Charts for attribute balance checking, categorical data proportion, etc. in a later lesson.

PYTHON
1fruits = ['Apple', 'Orange', 'Pineapple', 'JackFruit', 'Banana']
2amount = [23,17,35,40,12]
3
4fig = plt.figure()
5ax = fig.add_axes([0,0,1,1])
6ax.pie(amount, labels=fruits, startangle=90,shadow=True,explode=(0,0.2,0,0.1,0))
7ax.legend(labels=['Fruits'])
8fig.show()
9
10px.pie(values=amount, names=fruits, title='Fruits Distribution')

Pie Chart