2.6.3. How to Choose the Right Type of Plot
1. Introduction
Choosing the right plot is essential for effective data visualization. The best plot type depends on your data, your message, and your audience. This section provides guidance, practical tips, and R examples to help you make the best choice for your analysis and communication.
2. Key Principles for Choosing Plots
Barplots over Pie Charts:
- Barplots are easier for viewers to compare values across groups than pie charts.
- Human eyes compare bar heights more accurately than pie slice angles.
- Tip: Avoid pie charts for comparisons; use barplots instead.
Think Before You Plot:
- Consider what you want to communicate before making a plot.
- Choose a plot type that best matches your data and your message.
3. Be Mindful When Choosing Colors
- Choose Accessible Colors:
- Avoid colors that are hard to see on screens or projectors (e.g., pastels).
- Red-green color blindness is common; avoid using red and green together for key comparisons.
- Use color palettes designed for accessibility (see RColorBrewer, viridis).
R Code Example:
library(ggplot2)
ggplot(mtcars, aes(factor(cyl), fill = factor(gear))) +
geom_bar() +
scale_fill_brewer(palette = "Set2") +
labs(title = "Accessible Color Palette Example")
4. Label the Axes
- Always Label Axes Clearly:
- Use descriptive labels, not abbreviations.
- Labels should make it clear what is being plotted.
R Code Example:
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
labs(x = "Weight (1000 lbs)", y = "Miles per Gallon", title = "Car Weight vs. MPG")
5. Make Sure the Numbers Add Up
- Check Totals in Plots:
- For plots that should sum to 100% (e.g., pie charts, stacked barplots), verify that the numbers add up.
- Double-check your data and calculations before finalizing the plot.
Input Table:
| Category | Value |
|---|---|
| A | 45 |
| B | 30 |
| C | 25 |
Output Table:
| Category | Percent |
|---|---|
| A | 45% |
| B | 30% |
| C | 25% |
6. Make Sure the Numbers and Plots Make Sense Together
- Check Consistency:
- Ensure that labels, legends, and plot areas match the data.
- Avoid mismatches between what the plot shows and what the numbers say.
7. Make Comparisons Easy on Viewers
- Reduce Unnecessary Whitespace:
- Remove extra space between bars in barplots to make comparisons easier.
- Arrange bars logically (e.g., by value or category).
R Code Example:
ggplot(mtcars, aes(x = factor(cyl))) +
geom_bar(width = 0.8) +
labs(x = "Number of Cylinders", y = "Count")
8. Use y-axes That Start at Zero
- Avoid Misleading Axes:
- For numerical data, y-axes should start at zero to avoid exaggerating differences.
- Only use non-zero baselines when justified and clearly indicated.
9. Keep It Simple
- Simplicity Improves Understanding:
- Avoid clutter, unnecessary colors, and excessive annotations.
- Focus on the main message of your plot.
10. Questions to Ask Before Plotting
- What’s your main point?
- What type of data are you plotting (categorical, continuous, time series)?
- What comparison or trend do you want to highlight?
- Who is your audience?
- What is the best plot type for your data and message?
11. Emphasizing Your Point in Plots
- Add Data for Context:
- Compare your main data to relevant reference groups.
- Highlight with Color:
- Use color to draw attention to key data points.
- Annotate Your Plot:
- Add arrows, text, or highlights to emphasize important features.
R Code Example:
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
geom_point(data = subset(mtcars, mpg == max(mpg)), color = "red", size = 4) +
annotate("text", x = 3, y = max(mtcars$mpg), label = "Max MPG", vjust = -1)
12. Write Precise Descriptions and Add Sources
- Describe Clearly:
- Use figure legends, subtitles, and axis labels to explain what is shown.
- Add Data Sources:
- Always cite where your data comes from, especially in explanatory plots.
13. Exploring Beyond the Basics
- Use interactive plots (e.g., plotly, shiny) for deeper exploration.
- Try advanced color palettes and themes (e.g., viridis, ggthemes).
- Explore chart types at R Graph Gallery.
- Read more about color theory and accessibility in visualization.
14. Practice Problems
- Create a barplot comparing three groups, ensuring the y-axis starts at zero.
- Make a grouped barplot with accessible colors.
- Annotate a scatterplot to highlight an outlier.
- Check that your pie chart percentages add up to 100%.
- Write a clear title and axis labels for a boxplot.