Skip to content

Latest commit

 

History

History
28 lines (17 loc) · 881 Bytes

File metadata and controls

28 lines (17 loc) · 881 Bytes

Simple Pie Chart

Mike Driscoll is a machine and just keeps sharing great ideas. This tweet was about creating a simple pie chart in python. No pandas, just matplotlib and seaborn for the color palette.

Example Code

import matplotlib.pyplot as plt
import seaborn as sns

data = [15, 25, 25, 30, 5]
labels = ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5"]

colors = sns.color_palette("pastel")[0 : len(labels)]

plt.pie(data, labels=labels, colors=colors, autopct="%.0f%%")
plt.savefig("simple_pie_chart.png")

./simple_pie_chart.png

Code