R

Better bubble charts

A bubble chart is simply a scatterplot with the added feature that point sizes are proportional to the values of a third quantitative variable. Here is an example. Using the mtcars dataset, we’ll plot car weight vs. mileage and use point size to represent horsepower. We’ll use the ggplot2 package and rely on the defaults. # create a bubble plotdata(mtcars)library(ggplot2)ggplot(mtcars, aes(x = wt, y = mpg, size = hp)) +geom_point()Figure 1: Basic bubble plotWhile useful, we can improve on the default appearance by