Graphics Reference
In-Depth Information
Figure 5-6. Left: scatter plot with the shape aesthetic set to a custom value; right: with a variable
mapped to shape, using a custom shape palette
If you have mapped a variable to
shape
, use
scale_shape_manual()
to change the shapes:
# Use slightly larger points and use a shape scale with custom values
ggplot(heightweight, aes(x
=
ageYear, y
=
heightIn, shape
=
sex))
+
geom_point(size
=
3
)
+
scale_shape_manual(values
=
c(
1
,
4
))
Discussion
Figure 5-7
shows the shapes that are available in R graphics. Some of the point shapes (1-14)
have just an outline, some (15-20) are solid, and some (21-25) have an outline and fill that can
be controlled separately. (You can also use characters for points.)
For shapes 1-20, the color of the entire point—even the points that are solid—is controlled by
the
colour
aesthetic. For shapes 21-25, the outline is controlled by
colour
and the fill is con-
trolled by
fill
.