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.
A clean, labelled chart in an interview signals you can present findings â not just crunch numbers.
Figure & 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
Common 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
Labels & 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’)
Styling
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’)
Subplots & 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
Saving & 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
A typical case study deliverable. Note fig/ax, proper labels, gridlines, and peak annotation â all the details that get you hired.
“Explore this dataset visually” â subplots show you think like an analyst, not just a coder.
Visualisation rounds test design judgement as much as syntax.
The methods you will reach for in every interview charting task.
| Method | Purpose |
|---|---|
| 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 / ylabel | Labels 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