There are many ways to create a graph in R. We’ve focused on the use of ggplot2 because of its coherent grammar, flexibility, and comprehensiveness. The ggplot2 package was introduced in chapter 4, with coverage of geoms, scales, facets, and titles. In chapter 6, we created bar charts, pie charts, tree maps, histograms, kernel density plots, box and violin plots, and dot plots. Chapters 8 and 9 covered graphics for regression and ANOVA models. Chapter 11 discussed scatter plots, scatter plot matrices, bubble plots, line charts, corrgrams, and mosaic charts. Other chapters have covered graphs to visualize the topics at hand.
This chapter will continue the coverage of ggplot2, but with a focus on customization—creating a graph that precisely meet your needs. Graphs help you uncover patterns and describe trends, relationships, differences, compositions, and distributions in data. The primary reason to customize a ggplot2 graph is to enhance your ability to explore the data or communicate your findings to others. A secondary goal is to meet the look-and-feel requirements of an organization or publisher.