Graphics Reference
In-Depth Information
This will set different shapes and colors for the grouping variables (
Figure 5-5
, right):
ggplot(heightweight, aes(x
=
ageYear, y
=
heightIn, shape
=
sex, colour
=
sex))
+
geom_point()
+
scale_shape_manual(values
=
c(
1
,
2
))
+
scale_colour_brewer(palette
=
"Set1"
)
Figure 5-5. Left: mapping to both shape and colour; right: with manually set shapes and colors
See Also
To use different shapes, see
Using Diferent Point Shapes
.
For more on using different colors, see
Chapter 12
.
Using Different Point Shapes
Problem
You want to use point shapes that are different from the defaults.
Solution
library(gcookbook)
# For the data set
ggplot(heightweight, aes(x
=
ageYear, y
=
heightIn))
+
geom_point(shape
=
3
)