Change pie chart colors in Matplotlib

Python

Matplotlib

Pie

Change colors

Luc B.

Python

Matplotlib

Pie Chart

Matplotlib makes it easy to change a pie chart's colors to suit a particular color scheme.

Code Example

Use the colors parameter to the plt.pie() function to change the pie chart colors in Matplotlib.

import matplotlib.pyplot as plt

labels = ['Python', 'MATLAB', 'R', 'Julia']
values = [60, 20, 32, 13]
colors = ["magenta", "green", "purple", "orange"]

# Change pie chart colors here
plt.pie(values, labels=labels, colors=colors)

plt.show()

png