Graphics Reference
In-Depth Information
Figure 6-17. Left: box plot with narrower boxes; right: with smaller, hollow outlier points
If there are many outliers and there is overplotting, you can change the size and shape of the out-
lier points with
outlier.size
and
outlier.shape
. The default size is 2 and the default shape
is 16. This will use smaller points, and hollow circles (
Figure 6-17
, right):
ggplot(birthwt, aes(x
=
factor(race), y
=
bwt))
+
geom_boxplot(outlier.size
=
1.5
, outlier.shape
=
21
)
To make a box plot of just a single group, we have to provide some arbitrary value for
x
; other-
wise,
ggplot()
won't know what xcoordinate to use for the box plot. In this case, we'll set it to
1 and remove the x-axis tick markers and label (
Figure 6-18
):
ggplot(birthwt, aes(x
=
1
, y
=
bwt))
+
geom_boxplot()
+
scale_x_continuous(breaks
=
NULL
NULL
)
+
theme(axis.title.x
=
element_blank())