Pie Charts (and When Not to Use Them)
A pie chart shows how a whole splits into parts, with each slice an angle. ax.pie(sizes, labels=names, autopct='%1.0f%%') draws it and prints each percentage.
Humans judge angles poorly, so pies work only with a few slices (about five or fewer) and clearly different sizes. If the slices are similar, or there are many, a sorted bar chart is easier to read. Never use a pie when the parts do not add up to a meaningful whole.
When does a pie chart work well?
Draw the pie and print the angle of each slice in degrees, rounded to whole numbers (use [round(w.theta2 - w.theta1) for w in wedges]).
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.