Chapter 6 Basic Data Visualization
Learning Objectives
After completing this chapter, you will be able to:
- Create scatterplots, line plots, bar charts, histograms, density plots, and boxplots
- Use both base R
plot()and ggplot2 to produce visualizations - Map variables to aesthetics such as color, shape, and size
- Customize plot labels, themes, and legends
- Arrange multiple plots in a single figure
Equipped with the knowledge of different R objects in Chapters 2, 3, and 4, and knowing how to import data sets in Chapter 5, we are ready to dive into the colorful world of data visualization. In this chapter, you will learn the most commonly used kinds of plots that can be generated in R.
At a glance – Chapter ROADMAP
Section 6.1. Scatterplots: Visualize relationships between two continuous variables.
Section 6.2 & Section 6.3. Aesthetics: Customize plot appearance by mapping variables to color, shape, and size.
Section 6.5. Line Plots: Trace trends over time or ordered sequences.
Section 6.6. Smoothline Fits: Add regression lines and confidence intervals.
Section 6.8 & Section 6.8.4. Discrete Variables: Create bar charts and pie charts for categorical data.
Section 6.9, Section 6.10, & Section 6.11. Distributions: Explore the spread of continuous data using various plot types.
Section 6.12. Composite Figures: Arrange multiple plots into a single layout.