We can create a pie chart with plt.pie
.
budget = [50, 10, 7.5, 30, 10]
plt.pie(budget)
plt.axis('equal') # Set the axes to be equal
plt.show()
We can use labels
keyword to display category names of each slice
plt.pie(budget, labels=budget_categories)
To display the percentage of the total that each slice occupies, we use keyword autopct
and pass in a string format:
plt.pie(budget, labels=budget_categories, autopct='%0.1f')