Python ProgrammingPython Programming

How to pie Chart with different color themes in Matplotlib?

Different themes of Pie Chart:

import matplotlib.pyplot as plt

sizes = [12, 23, 11, 17, 19, 24, 29, 11, 12, 9, 7, 5, 3, 2, 1]
labels = ["Market %s" % i for i in sizes]

fig1, ax1 = plt.subplots(figsize=(5, 5))
fig1.subplots_adjust(0.3, 0, 1, 1)

theme = plt.get_cmap('copper')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes))
                             for i in range(len(sizes))])

_, _ = ax1.pie(sizes, startangle=90, radius=1800)

ax1.axis('equal')

total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100)
            for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.0, 1),
    bbox_transform=fig1.transFigure
)

plt.show()


Different themes of Pie Chart
theme = plt.get_cmap('hsv')


Different themes of Pie Chart
theme = plt.get_cmap('bwr')


Different themes of Pie Chart
theme = plt.get_cmap('jet')


Different themes of Pie Chart