Skip to content

Data Visualisation — Interview Questions

Questions on chart selection, design principles, and building visualisations in Python.


[Beginner] What chart type would you use to show the distribution of order values?

Show answer

A histogram — it shows how order values are distributed across bins (ranges). Add a KDE (kernel density estimate) overlay to show the smooth distribution shape.

import seaborn as sns
sns.histplot(df["total"], bins=30, kde=True)
plt.title("How Order Values Are Distributed")

For comparing distributions across groups (e.g., by category), use boxplots or violin plots — they show multiple distributions side by side without overplotting.


[Beginner] When should you use a pie chart vs a bar chart?

Show answer

Use a pie chart when: - You have 2-5 segments - The proportional relationship is the message ("Electronics is more than half of revenue") - The segments sum to a meaningful whole (100%)

Use a bar chart when: - You have more than 5 categories (angles are hard to compare) - The precise values matter, not just relative proportions - You need to compare across time periods or groups

Never use a pie chart when: - Slices are similar in size (impossible to compare angles) - You have more than 5-6 segments - You need to show change over time

In most analytics work, a horizontal bar chart is more readable than a pie chart for the same data.


[Mid-level] A stakeholder asks for a chart showing whether marketing spend "causes" revenue to increase. What would you create, and what would you caution them about?

Show answer

Chart to create: A scatter plot with marketing spend on x-axis and revenue on y-axis. Add a trend line (sns.regplot) and the Pearson correlation coefficient. Also show the time series of both metrics on a dual-axis chart.

Caution: I'd be explicit about correlation vs causation: - A positive correlation doesn't prove causation - Revenue might be growing for other reasons (seasonality, product launches, economic conditions) that also caused us to increase marketing spend - To establish causation, we'd need a controlled experiment (A/B test) or a regression controlling for other variables

I'd title the chart "Marketing Spend Correlated with Revenue (r = 0.78)" — not "Marketing Spend Drives Revenue."


[Mid-level] What is wrong with this chart and how would you fix it?

A bar chart showing revenue by region, where the y-axis starts at £42,000 instead of 0, making a 5% difference look like a 3x difference.

Show answer

The problem: A truncated y-axis visually exaggerates differences. The bar for the highest region looks 3-4x taller than the lowest, when the actual revenue difference is only 5-10%.

Why it matters: Stakeholders make decisions based on what charts look like, not what the numbers say. This misleads them into thinking there's a huge regional performance gap when there isn't.

Fix:

# Always start bar chart y-axis at 0
ax.set_ylim(0, max(values) * 1.1)  # add 10% headroom above highest bar

# If you want to highlight small differences legitimately:
# Option 1: Show the absolute difference directly (a different bar chart)
# Option 2: Label the bars with the actual percentage difference
# Option 3: Use a dot plot with a wider y range

Acceptable exception: line charts don't need to start at 0 — the slope matters, not the absolute height.


[Mid-level] How would you visualise the relationship between 5 numeric variables simultaneously?

Show answer

Pair plot (scatter matrix): shows every pairwise combination of variables as scatter plots in a grid. Diagonal shows distribution of each variable. Most informative but can be large.

import seaborn as sns
sns.pairplot(df[["var1", "var2", "var3", "var4", "var5"]], hue="category")

Correlation heatmap: shows the correlation coefficient between every pair. Faster to read than a pair plot, but loses distribution information.

sns.heatmap(df.corr(), annot=True, cmap="RdYlGn", center=0)

Parallel coordinates plot: each variable is a vertical axis; each observation is a line crossing all axes. Good for seeing clusters and patterns.

from pandas.plotting import parallel_coordinates
parallel_coordinates(df, "category")

Best approach: start with the heatmap to identify which pairs are most interesting, then build scatter plots for those pairs with trend lines and annotations.


[Senior] Your team produces 200 monthly charts (one per region × category combination). How would you automate this with Python?

Show answer
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd

df = pd.read_csv("orders.csv", parse_dates=["order_date"])
output_dir = Path("monthly_charts")
output_dir.mkdir(exist_ok=True)

regions = df["region"].unique()
categories = df["category"].unique()

for region in regions:
    for category in categories:
        subset = df[(df["region"] == region) & (df["category"] == category)]
        if len(subset) < 3:
            continue   # skip sparse combinations

        monthly = subset.groupby(subset["order_date"].dt.to_period("M"))["total"].sum()

        fig, ax = plt.subplots(figsize=(10, 5))
        ax.bar(monthly.index.astype(str), monthly.values / 1000, color="#0D9488")
        ax.set_title(f"Revenue — {region} / {category}")
        ax.set_ylabel("Revenue (£k)")
        ax.tick_params(axis="x", rotation=45)
        plt.tight_layout()

        filename = f"{region}_{category}.png".replace("/", "-").replace(" ", "_")
        fig.savefig(output_dir / filename, dpi=120, bbox_inches="tight")
        plt.close(fig)   # important: close figure to free memory

print(f"Saved {len(list(output_dir.glob('*.png')))} charts to {output_dir}/")

Key points: close figures with plt.close(fig) to avoid memory leaks; use Path for safe cross-platform file paths; skip sparse combinations; validate the output count.


← Mini Project · Next: Statistics for Analytics →