Interview prep

23 data visualization interview questions, with answers.

Data visualization interview questions with answers: choosing the right chart, honest design, matplotlib, seaborn and plotly, and the plots that matter when you build and evaluate models.

Visualization questions appear in data analyst, data scientist and ML engineer interviews, often as a chart to critique or a question about how you'd show a result to a manager. Interviewers want judgement: the right chart for the question, an honest scale, and a clear takeaway.

For tool questions, show you know when to use each library, not every argument.

These 23 questions are free. SchoolWhool's Foundations of AI course places 650+ interview questions right after the lessons they test, with a mock interview with Gaurav. See also the machine learning interview questions.

Choosing the right chart

How do you choose a chart type?
Start from the question. Comparing categories: a bar chart. A trend over time: a line chart. A distribution: a histogram, box plot or violin plot. A relationship between two numbers: a scatter plot. Parts of a whole: a stacked bar, or a pie only for two or three parts. Then pick the encoding people read most accurately for the comparison that matters, which is usually position or length.
What's the difference between a bar chart and a histogram?
A bar chart compares separate categories, with gaps between bars, and you can order the bars by value. A histogram shows the distribution of one continuous variable split into bins, with no gaps. Its shape depends on the bin width, so try a few widths before drawing conclusions.
When do you use a box plot, a violin plot or a histogram?
A box plot summarises median, quartiles and outliers compactly, which is ideal for comparing many groups. A violin plot adds the density shape, so it reveals two peaks a box plot would hide. A histogram shows one distribution in detail. With small samples, overlay the individual points, because box plots hide how few there are.
Why are pie charts criticised, and when are they fine?
People judge angles and areas less accurately than lengths, so slices of similar size are hard to compare and many slices become unreadable. A pie is fine for one part of a whole, or two or three categories. Otherwise a sorted bar chart communicates the same data better.
How do you show the relationship between two variables with many thousands of points?
A plain scatter plot overplots, so use transparency, smaller markers, a hexbin plot or a 2-D density plot. Add a smoothed trend line to show the pattern, and use a log scale for skewed variables. Sampling points is fine for exploration if you say so.
How do you visualise a correlation matrix?
A heatmap with a diverging colour scale centred on zero, values annotated, and variables ordered or clustered so related ones sit together. Remember that correlation only captures linear relationships, so check scatter plots for the important pairs.
How do you visualise high-dimensional data?
A pair plot for a handful of features; dimensionality reduction with PCA, t-SNE or UMAP to two dimensions; or parallel coordinates. Warn about t-SNE and UMAP: the distances between clusters and the cluster sizes in those plots aren't meaningful.

Honest, clear design

What makes a chart misleading?
Bar charts with a truncated axis, two y-axes with arbitrary scales, a cherry-picked time window, 3-D effects, unequal bins, and circles scaled by radius instead of area. Each uses true numbers to suggest a false conclusion. Pointing these out in a chart you're shown is a common interview task.
When is it fine for the y-axis not to start at zero?
For line charts and scatter plots, where position rather than length carries the value, zooming in to show variation is fine if the axis is clearly labelled. Bar charts must start at zero because the length of the bar is the value.
How do you choose colours?
Use a sequential palette such as viridis for ordered values, a diverging palette for values around a meaningful midpoint, and a qualitative palette for up to about eight categories. Avoid rainbow palettes like jet, which aren't perceptually uniform. Check for colour-blind safety and never rely on red versus green alone.
What is chart junk, and what is the data-ink ratio?
Edward Tufte's idea: most of the ink should show data, so remove what doesn't, such as heavy gridlines, 3-D effects, shadows and decorative backgrounds. Label lines directly instead of using a legend where you can. A title that states the takeaway does more than any decoration.
How do you design a chart for a non-technical audience?
One message per chart, stated in the title (for example, churn doubled after the price change). Highlight the series that matters in colour and grey out the rest, annotate the event that explains it, and use familiar chart types. If it needs a paragraph of explanation, simplify it.
How do you show uncertainty?
Error bars, saying whether they show a standard deviation, standard error or confidence interval; confidence bands around a line; whole distributions instead of single averages; ranges for forecasts. Showing only point estimates makes results look more certain than they are.

Tools: matplotlib, seaborn and plotly

What's the difference between a Figure and an Axes in matplotlib?
The Figure is the whole canvas; an Axes is one plot inside it, with its own axes, title and data. The object-oriented style, fig, ax = plt.subplots() then ax.plot(...), is clearer than the implicit plt. state machine, especially with several subplots.
When would you use matplotlib, seaborn or plotly?
Matplotlib is low-level with full control, best for static and publication figures. Seaborn is a high-level statistical layer on matplotlib that works directly with DataFrames, with hue and faceting built in. Plotly produces interactive HTML with hover and zoom and powers Dash dashboards. Choose by audience and medium.
How do you make small multiples?
plt.subplots(nrows, ncols, sharex=True, sharey=True) in matplotlib, relplot or catplot with col= and row= in seaborn, or facet_col in plotly. Shared axes keep comparisons between panels honest.
How do you save a figure for a report or slides?
fig.savefig('chart.png', dpi=200, bbox_inches='tight'), or SVG or PDF for sharp vector graphics. Set the figure size in inches before plotting, so fonts come out at a readable size rather than being scaled afterwards.
What makes a good time-series chart?
A proper datetime axis with readable tick labels, a rolling average or resampling to separate trend from noise, annotations for events, and gaps shown as gaps rather than joined with straight lines. Compare like with like, for example the same weekday or season.

Visualization for machine learning

Which plots do you make during exploratory analysis before modelling?
The target's distribution (to spot imbalance), each feature's distribution and missingness, features against the target, correlations, and key variables over time to check for drift. These plots catch data errors and leakage before they reach a model.
How do you visualise a classifier's performance?
A normalised confusion matrix, ROC and precision-recall curves (precision-recall is more informative when the positive class is rare), a calibration plot, and the distribution of predicted scores for each class. Scikit-learn's ConfusionMatrixDisplay, RocCurveDisplay and PrecisionRecallDisplay draw them from a fitted model.
How do you visualise a regression model's errors?
Plot predicted against actual values with a 45-degree line, residuals against predictions (a pattern means the model is missing structure, a funnel shape means the error grows with the value), a histogram of residuals, and errors broken down by segment.
What does a learning curve show?
Training and validation scores as the training set grows. A large, persistent gap means high variance, where more data or regularisation helps. Both scores low and close together means high bias, where a more flexible model or better features help.
How do you show feature importance or feature effects?
A bar chart of permutation importance with error bars, partial dependence and ICE plots for the shape of an effect, and SHAP summary plots. Always say that importance shows what the model relies on, not what causes the outcome.

First Principles, the SchoolWhool newsletter

One machine learning idea, explained properly, every week.

The intuition, the common mistake, and a five-minute way to try it yourself. Written by Gaurav.

Learn it properly, then the interview is the easy part.

Foundations of AI teaches data visualization and the rest of machine learning from first principles, with notebooks that check your work.