Graphics Reference
In-Depth Information
ggplot(heightweight, aes(x
=
sex, y
=
heightIn))
+
geom_boxplot(outlier.colour
=
NNA
, width
=
.4
)
+
geom_dotplot(binaxis
=
"y"
, binwidth
=
.5
, stackdir
=
"center"
, fill
=
NNA
)
Figure 6-31. Dot plot overlaid on box plot
It's also possible to show the dot plots next to the box plots, as shown in
Figure 6-32
. This re-
quires using a bit of a hack, by treating the xvariable as a numeric variable and subtracting or
adding a small quantity to shift the box plots and dot plots left and right. When the xvariable