Pie Charts

Pie Charts#

A pie chart is a circular graphic, divided into slices to illustrate numerical portion. The arc length of each slice (and thus its central angle and area) is proportional to the quantity it represents.

Data visualization and information perception research suggests that, while useful in some cases, making visual comparisons within a pie chart or across pie charts is challenging. This research recommends pie charts be replaced by other types of plots (scatter plots, density plots, bar charts, box plots, etc).

To learn more:

But, as Google’s design lead Manuel Lima has noted, humans love pie charts. So we’ll cover them.

%matplotlib inline
import matplotlib.pyplot as plt, numpy as np # import statements

labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' # slice labels
sizes = [15, 30, 45, 10] # slice sizes

fig, ax = plt.subplots() # create figure

ax.pie(sizes, labels=labels, autopct='%1.1f%%') # pie chart with custom labels
ax.axis('equal') # set equal aspect ratio to ensure pie is a circle

plt.show() # show plot

Additional Resources#

For more on pie charts: