Setting color of Pie chart - pyplot python mathplotlib module

Author: Al-mamun Sarkar Date: 2020-04-02 17:31:43

Setting color of Pie chart - pyplot python mathplotlib module. The following codes shows how to add color on Pie Chart using python mathplotlib module.

 

Import Module:

import matplotlib.pyplot as plt

 

Create Data:

slices_data = [70,20,20,130]
all_activities = ['sleeping','eating','working','playing']

 

Create plot and set chart color:

colors = ['c','m','r','b']
plt.pie(slices_data, labels=all_activities, colors=colors)
plt.title("Welcome to pie chart tutorial")
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.legend()
plt.show()