Selecting Visualizations for Data Analysis
Statistics & ExperimentsModel answerLast updated
Discuss which charts work best for different analytical goals, data types, and relationships during exploratory analysis.
You're conducting exploratory analysis on a new dataset and need to choose appropriate visualizations to understand the data and communicate findings.
Discuss the following:
-
Describe what a pie chart displays and its core limitations.
-
Under what circumstances is a pie chart appropriate? When should you avoid it?
-
Which visualization types are most valuable during exploratory analysis? Explain what each reveals about your data.
-
How would you visually investigate whether two variables are related? Consider different variable types (continuous, categorical) and practical challenges like large datasets.
Your answer should address how data type, analytical intent, and audience influence chart selection, and mention common visualization pitfalls.
Hints
Hint 1
Consider whether you're showing composition, distribution, comparison, or correlation
Hint 2
Think about how humans perceive visual encodings—length vs angle vs area
Hint 3
For large datasets, standard scatterplots may hide structure through overplotting
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Selecting Visualizations for Data Analysis
1. Pie Charts: Definition and Limitations
A pie chart represents proportions of a whole, where each category becomes a wedge whose size (angle and area) corresponds to its percentage of the total. All wedges combine to form a complete circle representing 100%.
The fundamental weakness is perceptual. Human vision ranks angles and areas poorly compared to linear position along a common scale. Research shows we misjudge wedge sizes, especially when comparing similar-sized slices or slices in different charts. This makes bar charts superior for nearly all comparison tasks.
2. When to Use or Avoid Pie Charts
Appropriate scenarios:
- Showing a simple breakdown with 2-4 categories where composition is the focus
- One category clearly dominates (e.g., "80% of traffic is mobile")
- The split approximates recognizable fractions (halves, thirds, quarters)
- Data represents true parts of a meaningful whole (mutually exclusive, exhaustive categories)
- Audience expects this format for simple share communications
Avoid when:
- You have many categories (≥6) or several small slices—use a sorted bar chart instead
- Categories have similar proportions that require precise comparison (18% vs 22%)
- Making temporal or cross-group comparisons—multiple pies force difficult angle matching across charts
- Values don't sum to 100% (overlapping categories, averages, rates, counts)
- Precision matters—exact percentages are hard to decode from angles
- Using 3D effects or separated slices, which distort perception
Bottom line: Pie charts serve narrow use cases. Horizontal bar charts ordered by value nearly always communicate the same information more clearly.
3. Essential Charts for Exploratory Data Analysis
EDA uncovers structure, identifies quality issues, and generates hypotheses. Organize by analytical goal:
Understanding distributions (numeric variables):
- Histograms: Reveal shape, skewness, modality, gaps, and potential outliers. Test multiple bin widths since binning choices affect interpretation.
- Box plots: Compactly show median, quartiles, and outliers. Efficient for comparing distributions across many groups.
- Density plots (KDE): Smooth alternative to histograms, though bandwidth selection matters.
Examining frequencies (categorical variables):
- Sorted bar charts: Display category frequencies in descending order. Immediately highlights dominant values and rare levels. Reveals data quality issues like inconsistent encoding ("CA" vs "California").
Tracking temporal patterns:
- Line charts: Essential for time-series data. Expose seasonality, trend breaks, anomalies, and missing dates. Connect sequential points to emphasize continuity.
Surveying many variables:
- Pair plots / scatter matrices: Grid of pairwise scatterplots for quick screening of relationships across multiple numeric variables.
- Correlation heatmaps: Color-coded matrix showing correlation coefficients. Useful for identifying multicollinearity and potential predictors among dozens of features.
Assessing data quality:
- Missing data visualizations: Bar chart of null percentages per column, or heatmap showing missing patterns across rows. Reveals systematic missingness (e.g., certain devices not logging specific fields).
Key practices:
- Apply log transformations to highly skewed distributions (revenue, page views) to avoid compression
- Always visualize alongside summary statistics—identical means and correlations can hide completely different distributions
- Use multiple complementary views rather than relying on a single chart type
4. Exploring Relationships Between Variables
Chart selection depends on variable types:
Two numeric variables: Scatterplots
The standard approach for continuous pairs (e.g., ad spend vs conversion rate).
What to examine:
- Direction and strength of association
- Linear vs nonlinear patterns
- Clustering or segmentation
- Outliers and influential points
- Heteroscedasticity (changing variance)
Handling overplotting with large datasets:
- Apply transparency (alpha blending) so density shows through overlapping points
- Use hexbin or 2D histogram to show point density in grid cells
- Create binned summaries: divide x into quantiles, plot mean y with confidence intervals per bin
- Sample data if patterns are clear from a subset
Enhancements:
- Add smoothers (LOWESS) or regression lines to highlight trends without assuming linearity
- Facet by a third categorical variable to check if relationships differ across subgroups (Simpson's paradox)
- Use log scales when variables span orders of magnitude
Numeric vs categorical: Box plots or violin plots
Display distribution of the numeric variable within each category level (e.g., order value by payment method). Strip plots work for smaller datasets. Bar charts showing means can mislead by hiding distributional shape and outliers.
Two categorical variables: Contingency tables as heatmaps
Visualize the cross-tabulation with color encoding counts or percentages. Stacked bar charts (especially 100% stacked) also work. This reveals associations like whether certain product categories correlate with specific user segments.
Time series pairs:
Overlay aligned line charts to spot co-movement. Be cautious—shared time trends create spurious correlation. Consider plotting changes or growth rates instead.
Example approach in code:
import seaborn as sns
import matplotlib.pyplot as plt
# Two numeric with density encoding for overplotting
sns.histplot(data=df, x="price", y="units_sold", bins=40, cmap="Blues")
plt.xscale('log')
plt.show()
# Add smoother, sample for visibility
sns.regplot(data=df.sample(10000), x="price", y="units_sold",
lowess=True, scatter_kws={"alpha": 0.1})
# Facet by category to check subgroup patterns
sns.lmplot(data=df, x="price", y="units_sold", col="product_type",
col_wrap=3, lowess=True, scatter_kws={"alpha": 0.2})
Quantify after visualizing: Compute Pearson correlation for linear relationships, Spearman for monotonic or skewed data. Remember correlation doesn't imply causation—both variables may respond to unobserved drivers.
Common Pitfalls
- Truncated bar axes exaggerating small differences (bars must start at zero; line charts need not)
- Too many pie slices or similar-sized wedges making comparison impossible
- Using single bin width in histograms and drawing conclusions from artifacts
- Overplotting millions of points into solid blobs, missing actual structure
- Reporting correlation alone without plotting—misses nonlinearity, outliers, and heteroscedasticity
- Ignoring confounding and subgroup effects (Simpson's paradox)
- Dual y-axes scaled to falsely suggest correlation between unrelated metrics
- Decorative color instead of encoding variables; non-colorblind-safe palettes
Summary
Effective visualization matches chart type to data type and analytical purpose. For composition with few categories, pie charts may suffice, but sorted bars are usually clearer. During EDA, histograms reveal distributions, scatterplots expose relationships, and faceting uncovers subgroup patterns. Address overplotting through transparency, binning, or sampling. Always pair visualizations with quantitative summaries, and remain alert to misleading design choices that distort perception or interpretation.