Data Visualization Interview Questions — Practice Real Interview Topics

Reviewed by Mark Dickie · Last updated

Data visualization is the practice of representing data in graphical or visual form so that patterns, trends, and outliers become easier to understand. For interviews, you should be ready to discuss chart selection, visual perception principles (Cleveland & McGill's encoding effectiveness hierarchy), color and accessibility guidelines, and the trade-offs between static and interactive approaches. Interviewers also expect familiarity with at least one major tool ecosystem, whether that is D3.js for the web, matplotlib/seaborn for Python, ggplot2 for R, or a BI platform like Tableau, plus the judgment to pick the right chart for a given data shape and audience.

What does a data visualization interview test?

Most interviews split into three areas: conceptual knowledge (when to use which chart, perceptual limits, color blindness), tool-specific implementation (writing or explaining code to produce a specific visual), and critique (identifying what is wrong with a given chart and proposing a fix). You may also get a take-home or whiteboard exercise asking you to design a visualization for a sample dataset.

EncodingBest ForWatch Out For
Bar chartComparing discrete categoriesMore than ~20 categories gets unreadable
Line chartTrends across a continuous variableCategorical, non-ordered data distorts the slope
Scatter plotRelationship between two numeric variablesOverplotting with large datasets; use sampling or alpha
HeatmapDensity or intensity across two dimensionsPrecise value comparison is hard without labels
Box plotDistribution summary and outlier detectionSmall sample sizes make quartiles misleading

How should you prepare for data visualization interview questions?

  1. Learn the perceptual encoding hierarchy from Cleveland and McGill: position on a common scale is read most accurately, followed by position on aligned scales, then length, angle, area, volume, and color saturation in decreasing order of accuracy.
  2. Study color theory basics, including sequential, diverging, and categorical palettes, and know which to use for each data type. Understand color-blind-safe palettes like Viridis.
  3. Practice building at least one chart from scratch in your tool of choice without relying on defaults: customize axes, labels, legends, and annotations.
  4. Review common bad-chart patterns and be able to explain the fix, including truncated y-axes, 3D pie charts, dual-axis bar/line combos, and rainbow color scales for sequential data.
  5. Get comfortable explaining your design choices aloud. Interviewers want to hear why you picked a bar chart over a line chart for a specific dataset, not just that you did.

Key facts

  • Tarmac has 98 Data Visualization interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
  • Tarmac last reviewed these Data Visualization interview questions on 31 August 2026.

At a glance

Questions25 shown · 98 in the bank
Difficulty1–5 of 5
FormatsMultiple choice, Flashcard, Find the bug, Multiple answer, True / false, Short answer, Fill in the blank, Ordering, Code output

What you'll review

  1. chart type fit
  2. small multiples
  3. colorblind safe palettes
  4. color scale types
  5. data ink ratio
  6. truncated axis
  7. preattentive attributes
  8. perceptual accuracy
  9. log scales
  10. charting library internals
  11. tufte principles

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

Data Visualization/chart-selection/chart-type-fit

You want to visualize how five categories contribute to a total (e.g., each department's share of an overall budget). The values sum to 100% and you want viewers to compare parts of a whole. Which chart type is most appropriate?#

Options

Show answer

A pie chart is the most appropriate choice for showing how a small number of categories contribute to a total, because each slice's angle is proportional to its share of the whole. Scatter plots, line charts, and histograms are designed for correlation, trends, and distribution respectively, not part-to-whole comparison.

Why:

A pie chart explicitly represents parts of a whole: each slice's angle is proportional to its share of the total. Scatter plots show correlation between two continuous variables, line charts show trends over a continuous interval, and histograms show the distribution of a single continuous variable — none of which are designed for part-to-whole comparison of a small number of categories.

Data Visualization/chart-selection/small-multiples

What is the small-multiples technique in data visualization?#

Show answer

A series of small charts, each showing one slice of the data — one panel per region, product, or year, for instance — laid out in a grid, all sharing identical axes, scale, and styling. Because every panel is visually identical except for the data it shows, a viewer compares patterns across slices just by scanning the grid with their eyes, instead of decoding a single cluttered chart with many overlapping series and a crowded legend. Tufte coined the term and described small multiples as behaving like consecutive frames of a film, where the constancy of the design lets the changing data do all the work.

Why:

Small multiples trade one complex chart for many simple, identical ones. The identical scale and layout across panels is what makes the comparison work — if one panel used a different y-axis range than the others, the visual comparison would silently become invalid even though nothing about the panels' appearance would signal that. This is the standard fix when a single chart with too many overlapping lines or bars becomes unreadable: split by the category causing the clutter instead of trying to force everything onto one set of axes.

Data Visualization/colour/colorblind-safe-palettes

The snippet below creates a heatmap meant to use a colorblind-safe colormap. It contains exactly one bug related to colorblind-safe palette usage. Which option correctly identifies the bug?#

import matplotlib.pyplot as plt
import numpy as np

data = np.random.rand(10, 10)
plt.imshow(data, cmap='jet')
plt.colorbar()
plt.title("Correlation Heatmap")
plt.show()

Options

Show answer

Line 4 — 'jet' is not a colorblind-safe colormap; a perceptually uniform, colorblind-safe alternative like 'viridis' should be used

Why:

The 'jet' colormap (line 4) interleaves red and green bands, making it difficult for red–green colorblind viewers to distinguish values. It also has non-uniform luminance, creating misleading perceptual bands. Matplotlib's 'viridis' colormap is perceptually uniform and colorblind-safe. The other options are factually wrong: imshow accepts float arrays, plt.colorbar works without an explicit handle, and plt.title accepts a string title.

Data Visualization/colour/color-scale-types

A dashboard shows percentage change in headcount by department, ranging from -30% to +45%, where 0% is a meaningful neutral midpoint (no change). Which color-palette type fits this field?#

Options

Show answer

A diverging palette — two contrasting hues that each fade toward a neutral color at a meaningful midpoint, such as blue through white to red — is the right choice whenever a value has a meaningful zero and can move in two directions, like percentage change in headcount running from -30% to +45%. A sequential palette assumes one direction with no meaningful midpoint, a categorical palette is for unordered groups rather than an ordered number, and a rainbow palette is actively misleading for quantitative data because its brightness doesn't change smoothly with value.

Why:

A diverging palette exists specifically for data with a meaningful zero or reference point and two directions of deviation from it — shrinking versus growing headcount is exactly that shape, so blue-to-white-to-red (or similar) lets a viewer read both the direction and the magnitude of change at a glance. A sequential palette assumes one direction with no meaningful midpoint, like population density, so applying it here would make -30% and +45% look like points on the same one-way scale instead of opposite outcomes. A categorical palette is for unordered nominal groups, not an ordered numeric quantity, and a rainbow palette is actively harmful for quantitative data because its luminance isn't monotonic — it introduces perceptual boundaries that don't correspond to real jumps in the underlying value.

Data Visualization/design-principles/data-ink-ratio

Per Tufte's data-ink ratio principle, which of these chart elements are classic examples of chartjunk that should usually be removed? Select all that apply.#

Options

Pick every one that applies.

Show answer

Tufte's data-ink ratio principle flags a 3D-extruded bar or pie effect with no data in the added depth, background gridlines drawn heavier than the data marks, and decorative drop shadows or textured backgrounds as classic chartjunk to remove, because none of them represent an actual value and the heavy gridlines actively compete with the data for attention. Axis tick labels and a legend are not chartjunk — they're the annotation a viewer needs to correctly decode the data-ink that remains.

Why:

The data-ink ratio is the proportion of a graphic's ink that represents actual data, and Tufte's advice is to maximize it by erasing ink that isn't data and toning down data-ink that's more prominent than it needs to be. A 3D bevel on a bar chart, heavy dominant gridlines, and decorative shadows/textures are the textbook chartjunk examples — none of them encode a value, and the gridlines in particular actively compete with the bars for visual attention they should be supporting instead. Tick labels and a legend are not chartjunk: they're exactly the annotation a viewer needs to decode the data-ink correctly, so removing them wouldn't raise the ratio, it would just make the chart unreadable.

Data Visualization/chart-selection/chart-type-fit

A pie chart is generally the best chart choice for letting viewers accurately compare eight or more slices of similar size.#

Options

Show answer

False. Pie charts encode value as angle and area, which people judge far less accurately than position or length, and that weakness gets worse as slice count grows and the slices approach similar sizes. A bar chart encoding the same values as bar length along a shared baseline lets a viewer rank and compare eight or more categories far more precisely.

Why:

False. Pie charts encode value as angle and area, which people judge far less accurately than position or length — and that weakness compounds as slice count grows and slices approach similar sizes, since the visual differences between wedges shrink toward the limit of what the eye can distinguish. A bar chart encoding the same values as bar length along a shared baseline lets a viewer rank and compare eight-plus categories far more precisely, which is exactly why style guides at most data teams cap pie charts at a handful of slices with clearly different sizes, or avoid them entirely in favor of a sorted bar chart.

Data Visualization/scales-and-axes/truncated-axis

A bar chart's y-axis starts at 90 instead of 0, so a difference between values of 92 and 95 makes one bar look several times taller than the other. Explain why this is misleading, and what you'd do instead.#

Show answer

A bar's length is what viewers read as the value, and that reading only works because bar length is implicitly proportional to a baseline of zero — a bar twice as tall is supposed to mean a value twice as large. Starting the axis at 90 breaks that proportionality: the visible bar for 92 is nearly the full height of the bar for 95, even though the real values differ by about 3%, so the chart visually exaggerates a small difference into what looks like a huge one. The fix is to start a bar chart's value axis at zero so bar length stays honest, and if the interesting variation really is a small slice of a large range, switch to a line chart or dot plot (where position, not length from a baseline, carries the meaning) or clearly annotate a zoomed/broken axis so the reader isn't misled without knowing it.

Why:

Bar charts work because length is read as proportional to value from a zero baseline — that's the entire visual contract. Truncating the axis away from zero keeps the numbers honest in the axis labels but makes the bars themselves lie: a 3% real difference renders as a dramatic visual gap, which is a textbook example of the kind of chart manipulation (deliberate or accidental) that erodes trust once a stakeholder notices the axis doesn't start at zero. Bars should start at zero; if the goal is to show fine variation in a narrow range, the right tool is a chart type where position rather than length-from-baseline carries the signal, or an axis break that's impossible to miss.

Data Visualization/visual-perception/preattentive-attributes

What are pre-attentive attributes in data visualization, and why do they matter for chart design?#

Show answer

Visual properties — color hue, size, orientation, position, and a handful of others — that the visual system registers within roughly 200-250 milliseconds, before conscious, focused attention kicks in, letting a viewer spot a highlighted point or an outlier instantly rather than scanning item by item. Chart design exploits this by reserving one pre-attentive channel for the single thing that should jump out, such as a lone red bar among gray ones; using several pre-attentive channels at once for unrelated purposes cancels the effect and forces the viewer back into slow, serial search.

Why:

Pre-attentive processing is why a single red dot in a field of gray dots is found instantly regardless of how many gray dots surround it, while finding a specific number in a grid of numbers takes time proportional to how many numbers there are. Designers use this deliberately — highlighting an anomaly with color, or an important series with a heavier stroke — but the effect is exclusive: if every series on a chart is a different bright color, nothing is pre-attentively distinct anymore and the viewer is back to reading the legend one item at a time.

Data Visualization/chart-selection/small-multiples

What is a small multiples chart (also called a trellis or faceted chart), and what is its primary purpose in data visualization?#

Show answer

A small multiples chart is a series of similar graphs or charts using the same scale and axes, displayed side by side (or in a grid), each showing a different subset of the data (e.g., one panel per category, region, or time slice). Its primary purpose is to make comparisons across groups easy while keeping each individual chart simple and uncluttered.

Why:

Small multiples repeat the same visual structure for different data slices, leveraging consistent scales so the viewer's eye can compare panels without re-learning the chart each time.

Data Visualization/colour/colorblind-safe-palettes

A colorblind-safe palette for categorical data should avoid pairing red and _____ in the same visualization, because these two hues appear nearly identical to viewers with deuteranopia or protanopia — the most common forms of color vision deficiency. Designers often substitute blue and orange, which remain distinguishable across all common color vision deficiencies.#

Show answer

A colorblind-safe palette for categorical data should avoid pairing red and green in the same visualization, because these two hues appear nearly identical to viewers with deuteranopia or protanopia — the most common forms of color vision deficiency. Designers often substitute blue and orange, which remain distinguishable across all common color vision deficiencies.

Why:

Red-green confusion is the hallmark of the most prevalent color vision deficiencies (deuteranopia and protanopia). Colorblind-safe palettes therefore avoid red-green pairings and instead rely on hues that differ in luminance or fall along the blue-orange axis.

Data Visualization/visual-perception/perceptual-accuracy

Per Cleveland and McGill's classic ranking of graphical perception tasks, which encoding channel do viewers judge quantitative values from most accurately?#

Options

Show answer

Cleveland and McGill's 1984 ranking of graphical perception puts position along a common, aligned scale — such as bar heights sharing one baseline, or dot position along a shared axis — at the top for judging quantitative values accurately, ahead of length, angle, area, and color shading in that order. This is the empirical basis for preferring a bar or dot chart over a pie or bubble chart whenever a viewer needs to compare values precisely.

Why:

Cleveland and McGill's 1984 study ranked the elementary perceptual tasks people use to decode a chart, from most to least accurate: position along a common scale, then position along non-aligned scales, then length, then direction/angle, then area, then volume, then color shading and saturation near the bottom. Position along a shared baseline is at the top because judging where something falls on a ruler is close to exact; area and angle require the viewer to mentally compare non-linear quantities, which is measurably less accurate and gets worse as the number of items grows. That's the empirical reason a bar or dot chart beats a pie or bubble chart whenever precise comparison matters — it isn't taste, it's how accurately the human visual system decodes each channel.

Data Visualization/colour/colorblind-safe-palettes

Which of these genuinely help make a chart's color encoding accessible to viewers with color-vision deficiency, such as red-green color blindness? Select all that apply.#

Options

Pick every one that applies.

Show answer

Making a chart's color encoding accessible to viewers with color-vision deficiency means choosing a colorblind-safe categorical palette such as ColorBrewer or Okabe-Ito, encoding the same distinction redundantly through a non-color channel like line style, marker shape, or a direct label, and avoiding red and green as the sole distinguishing pair since red-green deficiency is the most common form of color blindness. Simply increasing saturation on an arbitrary palette doesn't fix hue confusability, and a rainbow/jet colormap makes things worse — it isn't perceptually uniform and several of its bands look alike to colorblind viewers.

Why:

The three real fixes all attack the actual problem, which is hue confusability: a palette specifically vetted for color-vision deficiency (a), a non-color backup channel so color is never load-bearing on its own (b), and avoiding the single most common confusable pair, red/green, as the two colors doing the distinguishing work (c). Cranking up saturation on an arbitrary palette doesn't change which hues are confusable to a deuteranope — it can make the problem worse by pushing colors further into the exact wavelength range that's hard to tell apart. A rainbow/jet colormap is a well-documented anti-pattern for a different but related reason: it isn't perceptually uniform, it creates false visual boundaries where the data has none, and it's especially bad for colorblind viewers because several of its bands collapse into similar-looking colors for them.

Data Visualization/scales-and-axes/log-scales

A logarithmic axis can plot a data series that includes zero or negative values directly, with no transformation of the underlying data.#

Options

Show answer

False. A logarithmic scale plots the logarithm of each value, and log(0) is undefined while the logarithm of a negative number isn't a real number, so a zero or negative data point has nowhere to go on a plain log axis. Handling such data means offsetting it before taking the log, switching to a symmetric-log ('symlog') scale that goes linear near zero, or choosing a different scale entirely.

Why:

False. A log scale plots the logarithm of each value, and log(0) is undefined while the logarithm of a negative number isn't a real number, so any zero or negative point simply has nowhere to go on a plain log axis — most plotting libraries either drop it or throw. Handling data that legitimately includes zero or negative values means either shifting/offsetting the data before taking the log, using a symmetric-log ('symlog') scale that switches to linear near zero, or picking a different scale entirely. This trips people up in practice most often with metrics like profit/loss or year-over-year change, where a log axis looks attractive for the wide dynamic range but the series routinely crosses zero.

Data Visualization/rendering/charting-library-internals

This function is supposed to save one PNG chart per dataset. Instead, every PNG after the first shows all previously plotted series layered on top of each other, not just the current one. What's the bug?#

1| import matplotlib.pyplot as plt
2|
3| def save_charts(datasets):
4|     for name, series in datasets.items():
5|         plt.plot(series, label=name)
6|         plt.title(name)
7|         plt.legend()
8|         plt.savefig(f"{name}.png")

Options

Show answer

plt.plot() draws onto matplotlib's implicit global current figure/axes, and the loop never calls plt.figure() to start a fresh one or plt.clf()/plt.close() to clear the previous one between iterations, so each pass adds another line to the same figure instead of starting over

Why:

pyplot is a stateful wrapper: plt.plot(), plt.title(), and plt.legend() all act on whatever matplotlib currently considers the 'current figure' and 'current axes', and that state persists across loop iterations by design — it's what lets a notebook cell build up a chart across several plt calls. Because this loop never calls plt.figure() to open a new figure, or plt.clf()/plt.close() to clear the one it's reusing, every dataset's line gets added to the same growing figure, and plt.savefig() just renders whatever is currently on it — which is every series plotted so far, not just the current one. The fix is either plt.close() (or plt.clf()) at the top of each loop iteration, or switching to the object-oriented API (fig, ax = plt.subplots() per iteration) so each chart owns its own explicit figure instead of sharing pyplot's global state. Option (b) is independently wrong — an f-string genuinely produces a distinct filename per name, that part of the code works correctly.

Data Visualization/design-principles/tufte-principles

Explain Edward Tufte's data-ink ratio principle, and give one concrete example of simplifying a chart by applying it.#

Show answer

The data-ink ratio is the proportion of a graphic's ink (or pixels) that's devoted to actually representing data, versus everything else on the page — borders, background fills, heavy gridlines, redundant labels, decorative 3D effects. Tufte's principle is to maximize that ratio within reason: erase non-data ink that adds no information, and lighten data-ink that's more visually prominent than the information it carries requires. A concrete example is replacing heavy black gridlines behind a bar chart with thin light-gray ones (or removing them entirely and letting the bars' own alignment do the comparison work), and dropping the chart's outer border and background shading — none of that ink encodes a value, and removing it lets the bars themselves read more clearly instead of competing with their own frame for attention.

Why:

Tufte defined the data-ink ratio as data-ink divided by the total ink used in a graphic, and argued good design pushes that ratio up by erasing ink that carries no data and toning down data-ink that's louder than necessary. It isn't a call to strip everything — labels, legends, and axis ticks are data-ink's supporting cast and stay — it specifically targets ink that adds visual weight without adding information: heavy gridlines competing with the marks, decorative borders, 3D bevels, background textures. The workplace payoff is direct: a dashboard with a lower data-ink ratio takes longer to read because the eye has to filter out the noise before it gets to the signal, which matters most exactly when someone's glancing at a chart in a stand-up or a live incident.

Data Visualization/colour/colorblind-safe-palettes

Order the steps of choosing an accessible color encoding for a chart, from identifying the data to shipping a fallback for colorblind viewers.#

Put these in order

Show answer

Choosing an accessible color encoding runs in order: identify whether the field is nominal, ordinal, or quantitative, pick the matching palette family (categorical, sequential, or diverging), choose a specific colorblind-safe palette within that family such as ColorBrewer or Okabe-Ito, simulate common color-vision deficiencies against it to check the categories stay discriminable, and finally add a redundant non-color encoding — a pattern, label, or shape — as a fallback for whatever confusability the simulation surfaces. Each step depends on the decision made in the one before it.

Why:

Each step narrows the previous one's decision, so reordering them breaks the logic: you can't pick a palette family before knowing whether the data is nominal, ordinal, or quantitative, because that's exactly what determines whether categorical, sequential, or diverging is even the right shape. You can't choose a specific palette before settling on the family, since ColorBrewer's schemes are organized by family for that reason. Simulating color-vision deficiency only makes sense once an actual palette has been chosen — there's nothing to test against beforehand — and adding a redundant non-color encoding is the last line of defense, reserved for whatever confusability the simulation step surfaces, since if the palette alone worked perfectly there'd be nothing left to compensate for.

Data Visualization/chart-selection/chart-type-fit

You are building a dashboard that visualizes part-to-whole (composition) relationships — i.e., how categories contribute to a total. Select ALL chart types that are generally appropriate for this purpose.#

Options

Pick every one that applies.

Show answer

Stacked bar charts, treemaps, and pie charts (for a small number of categories) are appropriate for part-to-whole composition. Each encodes how segments contribute to a total. Line charts show trends over a continuous axis and scatter plots show relationships between two variables, so neither is suited for composition.

Why:

Stacked bar charts, treemaps, and pie charts all encode a part-to-whole relationship: each segment's area or length represents its proportion of the total. Line charts encode trends over a continuous axis (typically time), and scatter plots encode the relationship between two independent continuous variables — neither shows composition of a single total.

Data Visualization/chart-selection/small-multiples

Cleveland and McGill's seminal research ranked elementary perceptual tasks by how accurately people can decode quantitative information from them. Place these five visual encoding channels in order from MOST accurate (1) to LEAST accurate (5).#

Put these in order

Show answer

The Cleveland–McGill accuracy ranking, from most to least accurate, is: position along a common scale → length → angle → area → color hue. Position-based charts (scatter plots, dot plots, line charts) let viewers judge quantities most precisely, while hue is the least reliable channel for encoding magnitude because the human visual system processes color categorically rather than ordinally.

Why:

Cleveland and McGill's 1984 experiments established the accuracy hierarchy of perceptual tasks. Position along a common scale (e.g., dot/line plots) is decoded most accurately, followed by length (bar charts), then angle (pie chart slices), then area (bubble charts), and finally color hue, which is perceptually ordinal-imprecise and ranked lowest for quantitative comparison. This ordering directly informs chart-selection best practices: prefer position-based encodings over area- or hue-based ones for quantitative data.

Data Visualization/rendering/charting-library-internals

This D3 render function is called every time the underlying data array changes (e.g. after a filter is applied). After filtering the dataset down, the chart still shows bars for items that were just filtered out. What's the bug?#

1| function render(data) {
2|   const bars = svg.selectAll("rect").data(data, (d) => d.id);
3|
4|   bars.enter()
5|     .append("rect")
6|     .merge(bars)
7|     .attr("x", (d) => xScale(d.id))
8|     .attr("y", (d) => yScale(d.value))
9|     .attr("width", xScale.bandwidth())
10|     .attr("height", (d) => height - yScale(d.value));
11| }

Options

Show answer

The code never handles the exit selection — bars.exit().remove() is missing, so when a later call to render() passes a data array with fewer items than before, the <rect> elements bound to the ids that dropped out are never removed from the DOM and just keep accumulating

Why:

selection.data() splits the joined selection into three parts — enter (new data with no existing element), update (data still present), and exit (elements whose data disappeared) — and this code only ever handles enter and the merged enter+update. Nothing calls bars.exit().remove(), so a <rect> bound to an id that's no longer in data is simply left in the DOM forever; the next render adds new bars on top without ever clearing the stale ones, and after a few filter/render cycles the chart is silently drawing far more bars than the current dataset actually has. The one-line fix is adding bars.exit().remove(); right after the .data() call. Option (c) is a genuine misconception worth naming: .merge() is required precisely because attribute updates chained after .enter().append() only apply to the newly-entered elements — without merging in the update selection, existing bars would stop getting repositioned on every re-render, a separate and equally real D3 bug.

Data Visualization/chart-selection/chart-type-fit

When the analysis task is to compare individual subcategory values across multiple primary categories, a stacked bar chart is a better chart-type choice than a grouped bar chart because the stacked layout simultaneously encodes part-to-whole relationships and category totals in a single view.#

Options

Show answer

False. Stacked bars are worse for comparing individual subcategory values across primary categories because only the bottom segment shares a common baseline; every higher segment is offset by whatever sits beneath it, making magnitude comparison unreliable. Grouped bars put every subcategory on the same axis, which is the better encoding for that specific comparison task.

Why:

While stacked bars do show part-to-whole composition and overall totals, they are inferior to grouped bars for the specific task of comparing individual subcategory values across primary categories. Only the bottom segment of a stacked bar shares a common baseline; all higher segments are offset by the variable height of the segments below them, making it difficult to judge or compare their magnitudes visually. Grouped bars place every subcategory on the same axis baseline, enabling direct, accurate comparison at the cost of not showing totals — but for the stated task (comparing subcategory values), grouped bars are the better choice.

Data Visualization/chart-selection/small-multiples

A data-visualization team lays out small-multiples panels in a grid. The function below computes the grid dimensions and the number of empty cells in the last row, given the total number of facets n and a maximum number of columns max_cols. When n = 7 and max_cols = 3, what does this print?#

def small_multiples_layout(n, max_cols):
    cols = min(n, max_cols)
    rows = (n + cols - 1) // cols
    last_row_count = n - (rows - 1) * cols
    empty_last_row = (cols - last_row_count) if rows > 1 else 0
    return (rows, cols, empty_last_row)

print(small_multiples_layout(7, 3))
Show answer
(3, 3, 2)
Why:

With n=7 and max_cols=3: cols = min(7,3) = 3. rows = (7+3-1)//3 = 9//3 = 3. Since rows > 1, last_row_count = 7 − (3−1)*3 = 7 − 6 = 1, so the last row holds only one panel. empty_last_row = 3 − 1 = 2. The tuple returned is (3, 3, 2).

Data Visualization/chart-selection/small-multiples

The function below encodes a chart-selection decision tree for faceted / small-multiples visualizations. It chooses among heatmaps, density facets, small-multiples line charts, small-multiples scatter plots, and single-chart fallbacks based on the number of groups, points per group, whether the axis is temporal, and whether cross-group comparison is the goal. What does it print for select_facet_chart(12, 50, True, True)?#

def select_facet_chart(n_groups, n_points_per_group, has_time_axis, want_comparison):
    if n_groups > 20:
        return "heatmap"
    if n_groups <= 1:
        return "single_line" if has_time_axis else "scatter"
    if n_points_per_group > 1000:
        return "density_facets" if want_comparison else "heatmap"
    return "small_multiples_line" if has_time_axis else "small_multiples_scatter"

print(select_facet_chart(12, 50, True, True))
Show answer
small_multiples_line
Why:

n_groups=12 is not > 20 and not <= 1, so we skip the first two branches. n_points_per_group=50 is not > 1000, so we skip the density/heatmap branch. We reach the final return: has_time_axis is True, so the ternary selects "small_multiples_line". This reflects the design rationale: with a moderate number of groups (≤20), a manageable point count per group (≤1000), and a temporal axis intended for cross-group comparison, small-multiples line charts are the recommended encoding.

Data Visualization/rendering/charting-library-internals

Order the steps of re-rendering a D3 chart from a new data array using the modern selection.join() pattern, from the existing DOM to what the browser actually paints.#

Put these in order

Show answer

Re-rendering a D3 chart with the modern selection.join() pattern runs in a fixed order: select the existing elements bound to the previous render, call .data(newData, keyFn) to bind the new array and compute the enter/update/exit split, call .join("rect") to append entering elements, remove exiting elements, and return the merged selection, apply attribute updates to that merged selection, and only then does the browser repaint the SVG. Each step depends on the one before it — attributes must be applied to the selection .join() returns, and .join() needs the split that .data() just computed — so the order isn't arbitrary.

Why:

Each step depends on the one before it, which is what makes this a genuine pipeline rather than a set of independent actions. You can't bind data to elements you haven't selected yet, so select comes first. .data() needs to run before .join() because join reads the enter/update/exit split that .data() just computed — calling join first would have nothing to act on. .join() has to happen before the attribute updates because those updates are applied to the selection join() returns (the merged enter+update set); applying attrs to the pre-join selection would miss the newly entered elements entirely. And the browser can only paint the attributes that have actually been set on the DOM, so that's last by definition. This ordering is also exactly why .join() replaced the older explicit enter()/exit()/merge() pattern — it collapses steps two and three of the old five-step version into one call while preserving this same dependency chain.

Data Visualization/chart-selection/chart-type-fit

A dataset contains 12 product categories, each decomposed into 7 funding sub-sources. Two distinct communication goals must be met simultaneously: (a) compare the total magnitude across the 12 categories, and (b) compare the relative composition (share of each of the 7 sub-sources) across those same categories.#

Show answer

A stacked column chart with 7 segments per bar fails goal (b) because only the bottom-most segment is anchored to a common baseline (the x-axis). Segments stacked above are not aligned to a shared baseline, so the visual system must judge length from an arbitrary floating start point—length comparison degrades rapidly for non-baseline segments, especially with 7 layers and 12 categories. This is the baseline-alignment limitation of stacked bars. The better approach is small multiples (faceted charts): one panel per product category (12 panels), each containing a horizontal or vertical bar chart of the 7 sub-sources sorted by value and anchored to a shared zero baseline within the panel. This lets viewers compare composition within each category precisely, while the panel layout (optionally sorted by total magnitude) supports cross-category comparison of totals. If total-magnitude comparison is the higher priority, pair the small multiples with a separate sorted bar chart of the 12 category totals.

Why:

The core perceptual limitation is baseline alignment: in a stacked bar, only the first segment sits on the axis baseline; every higher segment's length must be inferred from two floating boundaries, which the human visual system does poorly—particularly with 7 segments and 12 bars. Small multiples (faceted bar charts, one per category) give every sub-source a shared zero baseline within its panel, solving composition comparison, while sorting panels by total preserves total-magnitude comparison.

Related interview questions

The other 73 questions

This page shows 25 and marks what you pick. That's as far as a page can go. A free account opens the other 73 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.