Exercises: Visualization Gallery

These exercises use the gallery as a reference. For each exercise, find the relevant chart type in the gallery, adapt the code to your data, and produce the chart.


Part A: Conceptual (6 problems)

A.1 ★☆☆ | Recall

Name the nine question categories in the gallery and give one chart type for each.

GuidanceComparison (bar), Composition (treemap), Distribution (histogram), Relationship (scatter), Trend (line), Geospatial (choropleth), Flow/Network (Sankey), Part-to-Whole/Ranking (waterfall), Specialized (radar).

A.2 ★☆☆ | Recall

How many chart types are in the gallery total?

Guidance50 chart types across 9 categories.

A.3 ★★☆ | Understand

For a dataset of monthly revenue by product line over 3 years, which gallery category fits best, and which 2-3 chart types would you consider?

Guidance**Trend** category (change over time). Consider: line chart (one line per product), stacked area (if composition matters), and slope chart (if comparing start vs. end). If the question is about composition rather than trend, also consider stacked bar (%).

A.4 ★★☆ | Understand

When should you use a lollipop chart instead of a bar chart?

GuidanceLollipop charts work well when there are many categories and bars would create dense visual weight. The thin stem + dot is visually lighter than a filled bar, which makes the chart less cluttered. Use lollipops for ranked lists with 15+ items; use bars for fewer categories or when exact magnitude comparison matters.

A.5 ★★★ | Analyze

A colleague wants to show "how budget is allocated across departments." Which gallery chart types could work, and which is best?

GuidanceOptions: pie (few departments), treemap (many departments with hierarchy), waffle (for a specific audience that finds it engaging), stacked bar % (if showing change over time). Best default: treemap if there is a hierarchy (department > team), pie if there are 5 or fewer departments. Avoid pie with more than 7 slices.

A.6 ★★★ | Evaluate

The gallery includes radar charts under "Specialized" with a note that they are "controversial." Why, and when are they appropriate?

GuidanceRadar charts are controversial because (1) area is hard to compare across shapes, (2) the axis order is arbitrary and affects perception, (3) most radar chart data could be shown more clearly as a grouped bar chart. They are appropriate when the "shape" of a multi-dimensional profile is the message (emotion profiles, skill assessments, product comparisons) and when the audience finds the circular format engaging.

Part B: Applied (10 problems)

B.1 ★☆☆ | Apply

Find the "lollipop chart" entry in the gallery and adapt the code to show the top 15 countries by GDP.

GuidanceCopy the lollipop code from Section 35.2. Replace the sample data with GDP data. Sort descending. Adjust axis labels.

B.2 ★☆☆ | Apply

Find the "waffle chart" entry and create a waffle showing 73% completion of a goal.

GuidanceCopy the waffle code from Section 35.3. Set total=100, completed=73. Use two colors for completed and remaining.

B.3 ★★☆ | Apply

Find the "dumbbell chart" entry and create a dumbbell comparing 2020 vs. 2024 values for 10 metrics.

GuidanceCopy the dumbbell code from Section 35.2. Replace with your metrics and values. Each row has a line from the 2020 value to the 2024 value with dots at each end.

B.4 ★★☆ | Apply

Find the "ridgeline/joy plot" entry and create a ridgeline of temperature distributions by decade.

GuidanceCopy the ridgeline code from Section 35.4. Group the climate data by decade. Each row is one decade's temperature distribution.

B.5 ★★☆ | Apply

Find the "slope chart" entry and create a slope chart comparing rankings in 2020 vs. 2024.

GuidanceCopy the slope code from Section 35.2. Two vertical axes (2020, 2024). Lines connect each entity's position across the two years. Highlight entities that changed rank dramatically.

B.6 ★★☆ | Apply

Find the "waterfall chart" entry and create a waterfall showing how revenue changed from Q1 to Q4 through additions and subtractions.

GuidanceCopy the waterfall code from Section 35.9. Set starting value (Q1 revenue), increments (new sales, upsells), decrements (churn, refunds), and ending value (Q4 revenue).

B.7 ★★★ | Apply

Find the "candlestick chart" entry and create a candlestick of stock prices for the last 30 trading days.

GuidanceCopy the candlestick code from Section 35.6. Use OHLC data (open, high, low, close) for each day. Plotly has `go.Candlestick` built in.

B.8 ★★☆ | Apply

Find the "Sankey diagram" entry and create a Sankey showing energy flow from sources to uses.

GuidanceCopy the Sankey code from Section 35.8. Define nodes (coal, gas, solar, electricity, heat, transport) and links (source -> target with values).

B.9 ★★☆ | Apply

Use the quick-reference decision table (Section 35.11) to select the best chart type for: "What percentage of total sales does each region contribute?"

GuidanceThe question is about composition (parts of a whole). The table recommends: pie (few regions), treemap (many regions), stacked bar % (over time). For a single-time-point snapshot with 5 regions, a pie chart or horizontal stacked bar is the simplest effective choice.

B.10 ★★★ | Create

Choose a dataset you are working with (or from the capstone). Use the gallery to identify the best chart type for your main question. Produce the chart using the gallery's code template.

GuidanceThis is the gallery's primary use case: look up the chart type, copy the code, adapt to your data. The exercise is to practice the lookup workflow so it becomes habitual.

Part C: Synthesis (4 problems)

C.1 ★★★ | Analyze

For each of the 6 capstone figures from Chapter 34, identify which gallery entry it corresponds to and verify the code matches.

GuidanceFigure 1 (trend) = line chart (Section 35.6). Figure 2 (scatter with regression) = scatter (35.5). Figure 3 (heatmap) = heatmap (35.5). Figure 4 (multi-panel) = small multiples using line + scatter. Figure 5 (violin by era) = violin (35.4). Figure 6 (correlation heatmap) = correlogram (35.5).

C.2 ★★★ | Evaluate

The gallery includes 50 chart types. Are there chart types you have encountered that are NOT in the gallery? What would you add?

GuidanceCommon omissions from any 50-type gallery: bullet charts, Gantt charts, word clouds, population pyramids, unit charts, sparkline grids, geographic flow maps. The gallery covers the most common types; niche types may be missing. The exercise is to notice the boundaries of any reference.

C.3 ★★★ | Create

Build your own mini-gallery: pick 5 chart types you use most often, write a one-paragraph guide for each, and save as a personal reference document.

GuidanceFor each chart type: when to use, when not to use, your preferred library, your go-to code snippet, and 2-3 design tips from experience. This personal gallery is faster to consult than the full 50-type version.

C.4 ★★★ | Evaluate

The book is now complete. Write a one-paragraph summary of what you will take away from it and how your visualization practice has changed.

GuidanceSubjective and personal. Common themes: "I now always use action titles", "I sketch before coding", "I use a brand system", "I think about the audience before the chart type", "I critique my own work with a rubric." The exercise closes the book with a personal reflection.

This is the final exercise in the book. The gallery is your permanent reference; the skills are yours to keep. Build good charts.