Key Takeaways — Chapter 14: Specialized Chart Types
1. Specialized Types Extend the Chapter 11 Vocabulary
The five essential chart types cover most visualization work. Specialized types cover the rest: heatmaps for 2D tabular data, contour plots for continuous 2D surfaces, polar plots for cyclical data, error bars and confidence bands for uncertainty, quiver and streamplot for vector fields. Each is designed for a specific data shape the essentials cannot handle well.
2. Heatmaps with ax.imshow or ax.pcolormesh
ax.imshow(data, cmap="RdBu_r") displays a 2D numpy array as a grid of colored cells. Use aspect="auto" for tabular data (so cells stretch to fill the Axes) and interpolation="nearest" (so cell boundaries stay sharp). For irregular grids with unequal cell sizes, use ax.pcolormesh(x_edges, y_edges, data) with explicit edge coordinates.
3. Diverging Data Requires Symmetric vmin/vmax
For a diverging colormap to work correctly, the neutral color must align with zero (or the meaningful midpoint). Set vmin=-abs_max, vmax=abs_max so that the midpoint of the colormap maps to the midpoint of the data. Letting matplotlib autoscale puts the neutral color at the data median, which may not be meaningful.
4. Contour Plots for Continuous 2D Surfaces
ax.contour(X, Y, Z) draws line contours at level curves. ax.contourf(X, Y, Z) fills the regions between contours. Use levels=N to specify the number of levels, and ax.clabel(cs, inline=True) to label line contours with their numerical values. For noisy data, smooth first before contouring.
5. Polar Plots for Cyclical Data
fig.add_subplot(projection="polar") creates a polar Axes. For compass or clock-style displays, set ax.set_theta_zero_location("N") and ax.set_theta_direction(-1). Use polar bar charts for wind roses and activity clocks. Do not use polar plots for non-cyclical data — wrapping linear data in a circle creates false impressions of continuity.
6. Error Bars with ax.errorbar
ax.errorbar(x, y, yerr=errors, fmt="o", capsize=4) plots data points with error bars. Use yerr=[lower, upper] for asymmetric errors. Use capsize for visible caps at the ends of the bars. Choose ecolor different from the marker color so errors do not blend with data.
7. Confidence Bands with ax.fill_between
ax.fill_between(x, lower, upper, alpha=0.2) creates a shaded region between two y-value arrays. Combined with a central line (ax.plot), it produces the "line with shaded confidence band" pattern standard for forecasts and continuous uncertainty. The where parameter lets you fill only specific regions (e.g., positive or negative values).
8. Hiding Uncertainty Is Dishonest
Chapter 4 established this; Chapter 14 implements it. Every measurement has noise, every estimate has a confidence interval, every projection has a range. Your charts should show uncertainty through error bars, confidence bands, or explicit notation. Point estimates without uncertainty imply precision the data does not support.
9. Match the Chart Type to the Data Shape
Before picking a specialized type, classify the data: is it a 2D table? a continuous surface? cyclical? a vector field? an estimate with uncertainty? Each classification points to a specific chart type. The chart type should match the shape; do not use a polar plot for linear data or a heatmap for smooth continuous functions.
10. Specialized Charts Combine with Standard Charts
Specialized types often appear alongside the essentials in multi-panel figures. A scientific paper figure might have a heatmap in panel (a), a line chart with errorbars in panel (b), and a polar plot in panel (c). The Chapter 13 layout techniques apply: use GridSpec to arrange specialized and standard charts in the same figure, and apply consistent styling to every panel.