Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 31 ยท Practice and Review

Data Visualization Interview Questions

Prepare for data visualization interviews: grammar of graphics, Plotly vs Bokeh vs Altair, performance, misleading charts, dashboards and accessibility.

Interviews for analyst, data scientist and front-end roles rarely ask you to recite a library's API. They ask whether you can choose a chart, explain why it is honest, and fix one that is slow or misleading. This lesson collects twenty-two typical questions with short answers you can say out loud, grouped by topic. Where an idea is easier to show than to say, there is a small runnable example (a stand-in, since Plotly, Bokeh and Altair cannot run on this site).

A good answer has three parts: a one-sentence definition, a reason it matters, and a concrete example. Practice giving each answer in under thirty seconds. If an answer feels shaky, follow the link to the lesson that covers it.

Grammar of graphics and how charts work

1. What is the grammar of graphics? A way to describe a chart as a combination of independent parts instead of picking from a menu of chart types: data, marks (point, bar, line), encodings (which column drives which visual channel), scales, coordinates and facets. Altair and Vega-Lite expose it directly; Plotly Express and Bokeh hide it behind functions. Its value is composability: a scatter plot with color and size is the same grammar with two more encodings.

2. What is the difference between a mark and a channel? A mark is the shape drawn for each row (bar, point, line). A channel is a property of that shape that can carry data: x, y, color, size, shape, opacity. "Encode price as the x channel of a point mark" is a complete sentence in the grammar. See How a Chart Works Inside.

3. What does a scale do, and why does it have an inverse? A scale maps a domain of data values to a range of visual values (numbers to pixels, categories to colors). Axes and marks share it, so they always agree. The inverse maps pixels back to data, which is how hover, click and zoom know which data you mean.

4. Declarative versus imperative charting: what is the trade-off? Declarative (Altair, Vega-Lite) means you describe what the chart is and the library decides how to draw it; specs are short, serializable and easy to test. Imperative (Matplotlib, much of Bokeh's glyph API) means you issue drawing steps; you get fine control at the cost of more code. Plotly sits in the middle: Plotly Express is declarative-ish, graph_objects is explicit.

The small program below shows the declarative idea in miniature: a spec is only data, and ordinary code can read it, describe it and validate it. The scale chosen for each channel follows from the field's data type, which is why Altair asks you to say :Q, :N, :O or :T.

Python A spec is just data you can read

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Changing one word in the spec (quantitative to nominal) changes the scale from a continuous axis to one slot per value. That is the behavior behind many "my numbers are treated as categories" bugs. Related: Altair and the Grammar of Graphics.

Choosing a library

5. When would you pick Plotly, Bokeh or Altair? Plotly for fast, polished interactive charts and Dash apps, with a huge chart catalogue (3D, maps, financial). Bokeh when you need a Python server pushing live updates, custom widgets, or tight control of the layout. Altair when the dataset is modest, you want concise declarative code and linked selections between charts. They all render in the browser with JavaScript; the choice is about workflow, not capability. See the introduction.

6. What does Plotly Express add on top of graph_objects? Express is a high-level API: one call builds a whole figure from a DataFrame, picking trace types and legends from column names. graph_objects builds the same figure dictionary explicitly, trace by trace. You can mix them: start with Express, then update_layout or add_trace. A Plotly figure is just a dictionary of data (traces) and layout; see Plotly figures.

7. Why does Altair refuse more than 5,000 rows by default? It embeds the data in the chart spec, so a large dataset makes a huge JSON document that every viewer must download. The limit is a guard rail. Aggregate first, load from a URL, or use a data server.

8. How do the libraries link two charts? Altair: a shared selection parameter used in add_params on one chart and transform_filter or condition on another. Bokeh: charts share a ColumnDataSource, so selecting rows in one highlights them in all. Plotly: a Dash callback reads one figure's selectedData and updates another figure. All three keep a piece of state outside the individual chart.

Performance

9. A scatter plot with a million points is slow. What do you do? First ask whether a reader can see a million points. Options in order of preference: aggregate (hexbin or 2D histogram), downsample, switch from SVG to canvas or WebGL (scattergl in Plotly, webgl output backend in Bokeh), or render server-side to an image with a tool such as Datashader and let the browser zoom request new tiles. More detail in Large Datasets and Performance.

10. Why is SVG slow for many points but fine for a bar chart? SVG creates one DOM element per mark. The browser must lay out and style each, and every interaction touches the DOM. A bar chart has dozens of elements; a scatter plot may have hundreds of thousands. Canvas and WebGL draw pixels directly, trading easy per-element events and styling for speed.

11. What is the danger of naive downsampling? Taking every n-th point can skip a spike, which is often the most important point in a time series. Better methods keep the extremes of each bucket (min and max) or choose points that preserve the visual shape (the LTTB algorithm). The example below makes the failure visible.

JS Every n-th point loses the spike; min and max keep it

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Both reduced series have 50 points, yet only one still shows that the sensor hit 95. If your chart exists to detect anomalies, the first method is a bug.

Misleading charts

12. Name four ways a chart can mislead. A truncated bar axis (bars no longer proportional), a dual axis that makes two unrelated lines appear correlated, area or radius encodings that exaggerate size differences, and cherry-picked time ranges. Also: 3D effects, unlabeled smoothing, and a color scale that implies order where there is none. See Testing Charts and Common Pitfalls.

13. Why must bar charts start at zero but line charts need not? A bar encodes a value by its length, so length must be proportional to the value from a true zero. A line encodes values by position and the slope between points; a zoomed axis shows change without distorting a length. A zoomed line chart should say that it is zoomed.

14. What is a lie factor? The ratio between the size of the effect shown in the graphic and the size of the effect in the data. A bar chart whose axis starts at 45 shows values 50 and 55 as bar heights 5 and 10: the picture says +100 percent, the data says +10 percent, a lie factor of 10.

15. When is a pie chart acceptable? When there are two to four parts, the parts sum to a meaningful whole, and you want to say "about half" or "a small slice". Otherwise a sorted bar chart is easier to read, because people compare lengths along a common baseline more accurately than angles.

Dashboards and storytelling

16. How do you decide what goes on a dashboard? Start from the decisions and questions of the audience, not from the available data. Each element answers one question: KPI cards for "how are we doing", a trend for "which way is it going", a comparison for "where is the problem". Remove anything that does not change what someone would do. See the sales dashboard project.

17. Why are small multiples often better than many colored lines? Beyond about five lines, color matching in the legend is slow and lines overlap. Small multiples give each group its own panel with shared axes, so shapes can be compared directly. The shared scale is the important part.

18. What makes a chart title good? It states the message, not the topic: "Support tickets doubled after the April release" instead of "Tickets by month". Subtitles carry the units and the period. See Storytelling with Charts.

Accessibility and color

19. How do you make a chart accessible? Give it a text alternative that states the main finding, provide the data as an HTML table, make sure meaning never depends on color alone (add labels, patterns or position), use palettes that work for color-vision deficiency, check contrast of text (4.5:1 for normal text), and support keyboard access for interactive parts. See Color, Labels and Accessibility.

20. Which kinds of color palette exist and when do you use each? Sequential (light to dark) for ordered magnitudes such as counts; diverging (two hues meeting at a neutral midpoint) for values with a meaningful center such as change or Likert agreement; categorical (distinct hues) for unordered groups, limited to about eight. Using a rainbow for ordered data is a classic mistake because it has no natural order and produces false boundaries.

Practical and process questions

21. How do you test a chart? Test the spec, not the pixels: assert the trace count, the data lengths, the axis titles and the scale types. Snapshot the JSON of the figure so that changes are visible in code review. Pin library versions, because defaults change between releases. See the testing lesson.

22. A stakeholder asks for "just add one more series" and now the chart is unreadable. What do you do? Explain the trade-off with the question the chart must answer. Offer alternatives: highlight one series and gray out the rest, facet by group, filter with a control, or move the detail to a table. The aim is the reader's understanding, not the number of lines.

Quick self-test

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. In the grammar of graphics, what is an encoding?

    An encoding connects a column to a channel. Marks, scales and axes then follow from it.
  2. 2. You downsample a sensor series by taking every 20th reading. What is the main risk?

    Rare extremes matter most in anomaly detection. Keep per-bucket minimum and maximum, or use a shape-preserving method such as LTTB.
  3. 3. Why can a line chart use a non-zero baseline while a bar chart cannot?

    A truncated bar misrepresents ratios. A zoomed line shows change honestly if the axis is labeled.
  4. 4. A Likert survey result has a neutral middle. Which palette type fits best?

    A diverging palette has two hues meeting at a neutral midpoint, matching a scale with opposite ends and a center.
  5. 5. Which is the best first step when a million-point scatter plot is slow?

    Reduce what must be drawn first; switch to canvas or WebGL if the points are really needed.

Summary

  • Answer in three parts: definition, why it matters, example.
  • Know the grammar of graphics vocabulary: data, mark, encoding, channel, scale, facet.
  • Choose libraries by workflow: Plotly for polished interactive charts and Dash, Bokeh for servers and widgets, Altair for concise declarative, linked charts.
  • For performance, reduce first (aggregate or downsample with extremes kept), then change renderer.
  • Bars start at zero; watch dual axes, area encodings and cherry-picked ranges.
  • Accessibility means text alternatives, tables, redundant encodings, safe palettes and contrast.
  • Test specs, pin versions, and fit the dashboard to the decisions it serves.

Next: Plotly, Bokeh and Altair Cheat Sheet