tezvyn:

Visualize two continuous and one categorical variable?

AI-drafted, machine-checkedintermediate

Tests your ability to map data to visual encodings. A great answer starts with a scatter plot, then adds the categorical data using color, shape, or faceting, explaining the tradeoffs. A red flag is suggesting a 3D chart, which is difficult to read.

WHAT THIS TESTS: This question tests your vocabulary and practical judgment for data visualization. The interviewer is looking for more than just naming a chart type; they want to see you map data dimensions (continuous, categorical) to visual encodings (position, color, shape) and articulate the tradeoffs. It separates candidates who just know chart names from those who understand how to build a readable, information-dense graphic.

A GOOD ANSWER COVERS: First, for the two continuous variables (e.g., session duration and money spent), the standard and most effective choice is a scatter plot. This places the variables on the X and Y axes to reveal correlation, clustering, and outliers. Second, to incorporate the third, categorical variable (e.g., device type), you should present multiple options and their tradeoffs. The primary methods are using color/hue (e.g., blue dots for mobile, orange for desktop), shape (e.g., circles for mobile, crosses for desktop), or faceting (creating separate 'small multiple' plots for each category). Third, you must discuss the pros and cons. Color is great for up to 5-7 categories but fails with more. Shape is only effective for 2-4 categories before becoming hard to distinguish. Faceting is the clearest and scales to more categories, but uses more screen space.

COMMON WRONG ANSWERS: Suggesting a 3D scatter plot is a major red flag. While theoretically mapping the three variables to X, Y, and Z axes, 3D plots are notoriously difficult for the human eye to interpret. Perspective distortion and occlusion (points hiding other points) make it nearly impossible to accurately judge values or compare clusters. Another common mistake is suggesting an inappropriate chart type, like a bar chart or line chart, which don't show the relationship between two continuous variables effectively. A weaker answer will only mention one method, like color, and not be able to offer alternatives when prompted.

LIKELY FOLLOW-UPS: Be prepared for scale questions like, "What if you have 500,000 data points?" This makes overplotting a key problem. A good response would involve using transparency (alpha), downsampling the data, or switching from a scatter plot to a 2D density plot or heatmap. Another follow-up is, "What if the third variable were also continuous?" The correct answer here is to use a different visual encoding, like point size (creating a bubble chart) or a color gradient (e.g., light to dark blue).

ONE CONCRETE EXAMPLE: To visualize session duration (X-axis) vs. money spent (Y-axis) by device type, I would start with a scatter plot. I would encode the 'device type' category using color: blue for desktop, green for mobile. If the plot was too dense or the device types overlapped significantly, I would switch to faceting. This would mean creating two separate scatter plots side-by-side, one for mobile and one for desktop, with identical X and Y axes. This makes it trivial to compare the distribution shapes for the two populations without any visual clutter.

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.