Chapter 18. Handling Overlapping Points
When we want to visualize large or very large datasets, we often experience the challenge that simple x–y scatterplots do not work very well because many points lie on top of each other and partially or fully overlap. And similar problems can arise even in small datasets if data values were recorded with low precision or rounded, such that multiple observations have exactly the same numeric values. The technical term commonly used to describe this situation is overplotting, which means that we are plotting many points on top of each other. Here I describe several strategies you can pursue when encountering this challenge.
Partial Transparency and Jittering
We first consider a scenario with only a moderate number of data points but with extensive rounding. Our dataset contains fuel economy during city driving and engine displacement for 234 popular car models released between 1999 and 2008 (Figure 18-1). In this dataset, fuel economy is measured in miles per gallon (mpg) and is rounded to the nearest integer value. Engine displacement is measured in liters and is rounded to the nearest deciliter. Due to this rounding, many car models have exactly identical values. For example, there are 21 cars total with 2.0 liter engine displacement, and as a group they have only four different fuel economy values: 19, 20, 21, or 22 mpg. Therefore, in Figure 18-1 these 21 cars are represented by only four distinct points, so that 2.0 liter engines appear ...