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()
theme = plt.get_cmap('hsv')
theme = plt.get_cmap('bwr')
theme = plt.get_cmap('jet')
2018-11-18T13:04:52+05:30
2018-11-18T13:04:52+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution