Matplotlib — Python Data Visualisation | Data Analyst Interview
📈 Data Visualisation

Matplotlib — The Foundation of Python Charts

Line, bar, scatter, histogram. Every Python visualisation library builds on Matplotlib — interviewers test if you can produce a clean, labelled, presentation-ready chart.

Core Concepts
What interviewers test in Matplotlib

A clean, labelled chart in an interview signals you can present findings — not just crunch numbers.

1Figure & Axes

The two layers of every Matplotlib chart. Understanding fig vs ax is the fastest way to look senior in a live coding test.

  • plt.subplots() returns fig, ax
  • ax object methods vs plt functions
  • Multiple axes on one figure

2Common Chart Types

Know the right chart for the right data — and the exact function for each type.

  • plot() — line / time series
  • bar() / barh() — categories
  • scatter() — relationships
  • hist() — distributions

3Labels & Titles

An unlabelled chart fails the interview. Always add axis labels with units, a clear title, and a legend for multiple series.

  • set_xlabel / set_ylabel with units
  • set_title(fontsize, fontweight)
  • legend(loc=’best’)

4Styling

Colours, markers, line widths — what separates a quick draft from a presentation-ready chart.

  • color, cmap, alpha
  • linestyle, linewidth, marker
  • plt.style.use(‘seaborn-v0_8’)

5Subplots & Dashboards

Multiple charts in one figure — for comparing distributions or building a simple dashboard in case study rounds.

  • plt.subplots(rows, cols)
  • fig.tight_layout()
  • sharex / sharey axes

6Saving & Exporting

Save charts at high resolution for reports and presentations — interviewers ask about this in take-home tasks.

  • savefig(‘chart.png’, dpi=300)
  • bbox_inches=’tight’
  • PDF and SVG for vector output
Interview Example 1
Monthly revenue trend with annotation

A typical case study deliverable. Note fig/ax, proper labels, gridlines, and peak annotation — all the details that get you hired.

import matplotlib.pyplot as plt
 
months = [‘Jan’,‘Feb’,‘Mar’,‘Apr’,‘May’,‘Jun’]
revenue = [120,135,158,142,175,195]
 
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(months, revenue, marker=‘o’, linewidth=2, color=‘#16a34a’)
ax.set_title(‘Monthly Revenue 2026’, fontsize=14, fontweight=‘bold’)
ax.set_xlabel(‘Month’); ax.set_ylabel(‘Revenue (ÂŁk)’)
ax.grid(True, alpha=0.3)
 
peak_i = revenue.index(max(revenue))
ax.annotate(f’Peak ÂŁ{max(revenue)}k’, xy=(peak_i, max(revenue)),
  xytext=(peak_i-1, max(revenue)+12), arrowprops={‘arrowstyle’:‘->’})
 
plt.tight_layout()
plt.savefig(‘revenue.png’, dpi=300, bbox_inches=‘tight’)
Interview Example 2
2×2 EDA dashboard with subplots

“Explore this dataset visually” — subplots show you think like an analyst, not just a coder.

fig, axes = plt.subplots(2, 2, figsize=(12, 8))
 
axes[0,0].hist(df[‘amount’], bins=30, color=‘#16a34a’, alpha=0.7)
axes[0,0].set_title(‘Order amount distribution’)
 
axes[0,1].bar(df[‘category’].value_counts().index,
           df[‘category’].value_counts().values)
axes[0,1].set_title(‘Orders by category’)
 
axes[1,0].scatter(df[‘discount’], df[‘amount’], alpha=0.5)
axes[1,0].set_title(‘Discount vs Amount’)
 
axes[1,1].boxplot(df[‘amount’])
axes[1,1].set_title(‘Amount outliers’)
 
plt.tight_layout(); plt.show()
Interview Questions
Real Matplotlib questions asked in 2026

Visualisation rounds test design judgement as much as syntax.

When would you use a bar chart vs a line chart?
Bar charts compare quantities across distinct unordered categories (revenue by country). Line charts show change over an ordered axis — usually time. Using a line chart for unordered categories implies a trend that isn’t there; interviewers notice this mistake.
What is the difference between plt.plot() and ax.plot()?
plt.plot() uses the implicit current-axes state — fine for quick scripts. ax.plot() uses the object-oriented API, which is clearer for multi-panel figures. In interviews, always prefer ax methods: it shows you understand the fig/ax separation.
How do you save a chart at print quality?
Use plt.savefig(‘chart.png’, dpi=300, bbox_inches=’tight’). dpi=300 gives publication resolution; bbox_inches=’tight’ trims whitespace. For figures that must scale infinitely (presentations, posters), save as PDF or SVG instead.
When should you use a histogram vs a bar chart?
Histograms show the distribution of a continuous variable using bins — bars touch. Bar charts compare counts of categorical values — bars have gaps. Using a histogram for categorical data (or vice versa) is a common mistake that signals weak visualisation fundamentals.
What makes a chart ‘interview quality’?
Clear title, labelled axes with units, a legend for multiple series, sensible axis limits, no chartjunk, high-contrast colours accessible to colour-blind viewers, and a story readable in 5 seconds without verbal explanation.
Quick Reference
Matplotlib cheat sheet

The methods you will reach for in every interview charting task.

MethodPurpose
plt.subplots(rows, cols)Create figure and axes
ax.plot(x, y)Line chart
ax.bar(x, height)Vertical bar chart
ax.barh(y, width)Horizontal bar chart
ax.scatter(x, y, alpha)Scatter plot
ax.hist(data, bins)Histogram
ax.boxplot(data)Box plot for outlier detection
ax.set_title / xlabel / ylabelLabels and title
ax.legend(loc=’best’)Show series legend
ax.grid(True, alpha=0.3)Add subtle gridlines
ax.annotate(text, xy, xytext)Add callout annotation
plt.savefig(path, dpi=300)Export at print quality

Ready to ace your visualisation round?

Practise live Matplotlib questions with feedback on chart design and presentation.

Book Free Matplotlib Session