Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
To compare multiple groups, it’s possible to stack the dots
along the y-axis, and group them along the x-axis, by setting binaxis="y". For this example, we’ll use the
heightweight data set (Figure 6-30):
library(gcookbook)# For the data setggplot(heightweight,aes(x=sex,y=heightIn))+geom_dotplot(binaxis="y",binwidth=.5,stackdir="center")
Dot plots are sometimes overlaid on box plots. In these cases, it may be helpful to make the dots hollow and have the box plots not show outliers, since the outlier points will be shown as part of the dot plot (Figure 6-31):