How would you visualize high-cardinality categorical relationships?

This tests dimensionality reduction when categories exceed roughly fifty levels. A strong answer proposes top-N aggregation with an other bucket and density or hierarchy plots like heatmaps or treemaps. A red flag is scrolling a bar chart or sampling rows.
What's really being asked
The interviewer wants to see if you understand visual encoding limits and can move beyond default bar charts when cardinality explodes. With zip codes or product IDs, a standard bar plot becomes unreadable because human working memory cannot track thousands of discrete positions. The question probes your knowledge of information reduction, hierarchical aggregation, and alternative visual forms that trade individual identity for pattern detection.
The full answer
First, information reduction techniques. You should mention filtering to top-N categories by frequency or a numeric metric and bundling the remainder into an other bucket. You can also group by a higher-level hierarchy such as city or product category to collapse cardinality. Second, alternative encodings that do not require one mark per category. For a single numeric variable across many categories, lollipop charts or dot plots reduce ink and improve readability. For part-to-whole relationships, treemaps or circular packing use nested area to show hierarchy. For relationships between a high-cardinality category and a numeric distribution, violin plots, box plots, or ridge lines replace hundreds of bars with density shapes. For two categorical variables, a heatmap with color intensity handles far more combinations than grouped bars. Third, interactivity as a supplement, not a crutch, such as searchable tooltips or drill-down from summary to detail.
The mistakes people make
A junior answer suggests rotating the bar chart or using a horizontal layout, which does not solve the fundamental overplotting problem. Another red flag is proposing to sample the data randomly, because that hides long-tail behavior and outliers that are often the most actionable insights. Simply using a smaller font or scrolling is also unacceptable at a senior level because it offloads cognitive load to the reader instead of the designer.
What usually comes next
The interviewer may ask how you would handle a third variable, which opens discussion about faceting small multiples or using color and size channels in a scatter plot. They might also ask how you would communicate the missingness of the other bucket, leading to a discussion of Pareto charts or cumulative percentage lines. Finally, they could probe scalability by asking what you would do with millions of distinct IDs, which pushes toward database-level pre-aggregation or switching to entirely different paradigms like search interfaces rather than static plots.
A concrete example
Suppose you have one million transactions across twelve thousand product IDs and want to show revenue per product. A strong approach is to create a Pareto chart of the top fifty products by revenue, grouping the rest into other, and overlay a cumulative percentage line so stakeholders see that the top fifty drive eighty percent of sales. For the full distribution, you render a violin plot of log revenue by product category instead of by individual product, preserving the shape of the long tail without twelve thousand bars.
Interview question
When plotting a numeric metric across tens of thousands of categories, which strategy best preserves analytical value while respecting visual encoding limits?
- a.Aggregate to top-N categories with an 'other' bucket and use density or hierarchy plotsCorrect
- b.Decrease font size and enable scrolling so all bars remain individually visible
- c.Randomly sample rows to reduce the number of bars displayed
- d.Rotate the bar chart labels and use a horizontal layout to fit all category names
Why? this is the answer
Aggregating to top-N with an 'other' bucket and using density or hierarchy plots reduces dimensionality without hiding long-tail behavior; rotating or horizontal bar charts merely rearrange the same overloaded marks and fail to solve overplotting.
Just read this? Test yourself on what you have been reading.
Read the original → data-to-viz.com
- #data visualization
- #high cardinality
- #categorical data
- #chart selection
- #eda
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on data visualization — each one lists the topics its interview covers.
See open roles