Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Data Analysis with Python (pandas, polars, DuckDB) Module 10

Visualising data with matplotlib interview questions

Interview questions on visualising data with matplotlib: warm-ups, then what each harder question tests and how a good answer starts.

15 questions: 4 warm-ups and 11 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher

    Why should a bar chart's value axis start at zero, when a line chart's axis need not?

    Answered in the lesson Choosing the right chart for the question

  2. Fresher

    What is the difference between a Figure and an Axes in matplotlib, and why do many analysts start every chart with fig, ax = plt.subplots()?

    Answered in the lesson Plotting with matplotlib and pandas

  3. Fresher

    When would you show a distribution as a box plot rather than a histogram, and what can a box plot hide?

    Answered in the lesson Distributions, relationships and correlation charts

  4. Fresher

    Why do many chart guides prefer labelling lines directly to using a legend, and when is a legend still the better choice?

    Answered in the lesson Charts that communicate: annotation, accessibility

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Fresher to mid

    Leadership wants a pie chart of the company's 14 cost categories for the annual summary. What do you propose instead, and how do you deal with the smallest categories without hiding anything?

    What it tests
    Choosing a part-to-whole chart from the question behind it, keeping every part of the whole, and writing a title that carries the finding.
    First step
    Ask which decision the summary supports: which costs are largest, how the mix changed since last year, or whether one category is out of line. Each answer points to a different chart, and none of them is a pie with 14 slices, where a 1 % category is a sliver of 3.6 degrees.
    Follow-ups

    From the lesson Choosing the right chart for the question

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to senior

    A product manager wants one chart of daily active users and daily revenue over six months, on two y-axes, to show that revenue follows usage. What do you build instead, and what do you say about the claim?

    What it tests
    Why two y-axes mislead, how to compare two series on one honest scale, and the gap between moving together and one causing the other.
    First step
    Put both series on a common footing before drawing anything: divide each by its average in the first week and multiply by 100, so each first-week average is 100 on one axis; individual daily points can differ. Then ask which ratio would stay flat if the claim were true, and plot that as well.
    Follow-ups

    From the lesson Choosing the right chart for the question

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Fresher to mid

    The value labels on a revenue bar chart read 4.41e+06, 3.72e+06 and so on, and the y-axis runs from 0.5 to 2.0 with a small 1e6 above it. Explain both effects and fix the chart so that nobody has to count zeros.

    What it tests
    Knowing matplotlib's default formats for value labels and ticks, choosing one unit for the reader, and keeping the axis and the labels consistent.
    First step
    Treat them as two separate defaults, one for the value labels and one for the axis, and look up what each one does with large numbers before changing anything. Then choose one unit for the whole chart, such as millions with two decimals, so that the labels and the ticks end up saying the same thing.
    Follow-ups

    From the lesson Plotting with matplotlib and pandas

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    A nightly job saves 40 charts as SVG files into a Git repository. Every night all 40 files show up as changed, even on nights when the data did not change. What is going on, and how do you make unchanged charts produce unchanged files?

    What it tests
    What makes matplotlib's SVG output differ between runs, the settings and conventions that make it reproducible, and how to keep it that way across machines.
    First step
    Diff two of the files instead of guessing. If the data and the drawing did not change, the lines that differ are not data: find which parts of the SVG text change between two saves of the same chart, then look for the settings that control them.
    Follow-ups

    From the lesson Plotting with matplotlib and pandas

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Mid to senior

    A script draws one chart per store for 3,000 stores. It gets slower and slower and is killed for using too much memory after a few hundred charts. What is happening, and how do you restructure it?

    What it tests
    How pyplot keeps figures alive, closing figures or avoiding pyplot, reusing one figure, and measuring memory instead of guessing.
    First step
    Count the open figures while it runs: plt.get_fignums() grows by one per store, because pyplot keeps every figure it created until it is closed. Then check the job's log for warnings from matplotlib, and measure the process's memory every hundred stores instead of guessing.
    Follow-ups

    From the lesson Plotting with matplotlib and pandas

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  6. Fresher to mid

    Two analysts plot the same 400 delivery times. One histogram shows one peak, the other shows two. Who is right, and how do you decide what to show the operations team?

    What it tests
    Knowing that the bin width shapes a histogram, checking a shape before trusting it, and choosing a chart that does not depend on a single bin choice.
    First step
    Do not pick a winner from the two pictures. Redraw the same data at several bin widths and draw an ECDF, which has no bins at all. Check whether the proposed groups remain plausible across these choices and in the unbinned values; neither a chosen width nor two steep ECDF stretches proves two population modes.
    Follow-ups

    From the lesson Distributions, relationships and correlation charts

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  7. Mid to senior

    A correlation heatmap of 30 product metrics shows r = 0.02 between discount depth and units sold, and a manager concludes that discounts do not affect sales. What do you check before agreeing, and what do you show instead?

    What it tests
    What Pearson's r measures, the shapes and subgroups it misses, and why a correlation, high or low, is not evidence about cause.
    First step
    Draw the scatter plot behind the number before discussing it. A near-zero sample r reports little linear association in that sample; it does not rule out a population relationship. Check curves, cancelling subgroups, extreme products, restricted ranges and sample uncertainty.
    Follow-ups

    From the lesson Distributions, relationships and correlation charts

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  8. Mid to senior

    A scatter plot of 2 million orders, order value against delivery time, is one solid blob. How do you show the relationship, and how do you check whether a trend line through it means anything?

    What it tests
    Remedies for overplotting, summarising a relationship with binned statistics, and judging a trend line by its residuals and its range.
    First step
    Stop drawing every point. Count the points per cell with hexbin or a 2D histogram, or plot a random sample of a few thousand, and add the median delivery time for each band of order value, which shows the trend without any fitted line.
    Follow-ups

    From the lesson Distributions, relationships and correlation charts

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  9. Fresher to mid

    A dashboard marks each region red when it misses its target and green when it meets it. A colleague with a red-green colour-vision deficiency says the two states look the same. What do you change, and how do you check that the fix works?

    What it tests
    Not relying on colour alone, adding a second cue, choosing colours that stay distinct for colour-blind readers, and checking a design with a simulator and contrast ratios.
    First step
    Treat it as a design fault, not a matter of taste: WCAG 2.2 requires that colour is not the only visual means of conveying information. Add a cue that needs no colour at all, such as the words "below target", an icon or a shape, before choosing better colours.
    Follow-ups

    From the lesson Charts that communicate: annotation, accessibility

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  10. Fresher to mid

    You publish a line chart of monthly complaints in a public report. Write the alt text and the long description you would give it, and explain what a screen-reader user needs beyond the chart's title.

    What it tests
    Writing text alternatives that carry the finding and the numbers, splitting a short alt text from a long description, and avoiding filler.
    First step
    Start from the finding the chart was drawn to show, not from how it looks. The alt text names the kind of chart, what it measures and the finding with its key number, in about a sentence; everything else a sighted reader could read off the chart goes into the long description.
    Follow-ups

    From the lesson Charts that communicate: annotation, accessibility

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  11. Mid to senior

    Stakeholders want all 12 regions on one line chart so that they can compare them. What do you build, and how do you keep the comparison honest?

    What it tests
    Replacing a tangle of lines with small multiples or highlighting, choosing shared scales or an index on purpose, and ordering and labelling for the question asked.
    First step
    Ask which comparison they need: which region is largest, which grew fastest, or how one region compares with the rest. Twelve tangled lines answer none of these well, and each question has a better chart, usually small multiples on one shared axis.
    Follow-ups

    From the lesson Charts that communicate: annotation, accessibility

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Data Analysis with Python (pandas, polars, DuckDB) interview questions · The Data Analysis with Python (pandas, polars, DuckDB) track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.