liveBook · Manning

Cooking chart family

As explained in Data Storytelling with Altair and AI

A cooking chart family is a book-specific grouping of pie charts and donut charts for showing parts of a numerical whole.

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

How Data Storytelling with Altair and AI covers it

How deep it goes
Defines pie and donut charts, gives selection constraints, and walks through labeled Altair implementation while deferring donut code.
Examples
Uses a 70% value with a 30% complement, then adds colored slices, tooltips, and labels in Altair.
What you can do after
Builds a labeled pie chart in Altair from a pandas DataFrame and saves it as an HTML file.
How it connects
Connects parts of a whole with audience, message, insight, chart choice, pandas, Altair, and data storytelling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Storytelling with Altair and AI. The section links point to the parts of the book it draws on.