Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In the call to the geom, set the values of colour or fill (Figure 12-1):
ggplot(mtcars,aes(x=wt,y=mpg))+geom_point(colour="red")library(MASS)# For the data setggplot(birthwt,aes(x=bwt))+geom_histogram(fill="red"),colour="black"
In ggplot2, there’s an important difference between
setting and mapping aesthetic
properties. In the preceding example, we set the color of the objects to
"red".
Generally speaking, colour
controls the color of lines and of the outlines of polygons, while
fill controls the color of the fill
area of polygons. However, point shapes are sometimes a little
different. For most point shapes, the color of the entire point is
controlled by colour, not fill. The exception is the point shapes
(21–25) that have both a fill and an outline.