13.4 Pie charts
Another common chart type is the pie chart, where we visualize data as wedges. The size of each wedge is related to its data value compared to the sum of the values. We use the pie function to create a pie chart.
import matplotlib.pyplot as plt
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
support_calls = [21, 14, 10, 9, 19]
# draw the pie chart
pie_chart = plt.pie(support_calls, labels=days)
<Figure size 432x288 with 1 Axes>
plt.show()
matplotlib automatically assigns colors to each wedge. The last chart had wedges in blue, purple, red, green, and orange, starting with Monday, though they may appear monochromatically to you depending on the medium in which you are reading this book.
We provide many of the stylistic controls for the display of the chart as keyword arguments
to pie. If I add the argument autopct...