The cooking chart family groups pie charts and donut charts for showing numerical parts of a whole. Use it when the slices sum to 100%, only two or three unequal parts matter, and the audience needs an overview rather than precise comparisons. section 6.3.1
These charts are not automatically wrong: they communicate composition effectively, even though slice dimensions are difficult to compare precisely. Choose them for the point, audience, and message rather than by an absolute rule. section 6.3.1 section 6.3
A cooking chart fits when:
- The data represents components contributing to one complete system, object, or concept. section 6.3.1
- The total of all slices equals 100%, with no more than two or three visibly different slices. section 6.3.1
- The goal is a broad overview for a general audience, not detailed numerical comparison. section 6.3.1
Representing 70% of a whole
Create two values—70% and its 30% complement—in a pandas DataFrame. Encode the percentages as pie-slice angles, use color to distinguish the slices, and add labels such as “70%” and “30%.” section 6.3.1
Listing 6.3 The code to generate a basic pie chart
chart = alt.Chart(df).mark_arc(
).encode(
theta=alt.Theta('percentage', stack=True), #1
color=alt.Color('color', scale=None),
tooltip='label'
).properties(
width=300,
height=300
)
chart.save('pie-chart.html')
Inspect the runnable Altair pattern: encode percentage as theta, label as tooltip, color the slices, and save the result as HTML. section 6.3.1
