Graphics Reference
In-Depth Information
Setting the Positions of Tick Marks
Problem
You want to set where the tick marks appear on the axis.
Solution
Usually ggplot() does a good job of deciding where to put the tick marks, but if you want to
change them, set breaks in the scale ( Figure 8-12 ) :
ggplot(PlantGrowth, aes(x = group, y = weight)) + geom_boxplot()
ggplot(PlantGrowth, aes(x = group, y = weight)) + geom_boxplot() +
scale_y_continuous(breaks = c( 4 , 4.25 , 4.5 , 5 , 6 , 8 ))
Figure 8-12. Left: box plot with automatic tick marks; right: with manually set tick marks
Discussion
The location of the tick marks defines where majorgrid lines are drawn. If the axis represents a
continuous variable, minorgrid lines, which are fainter and unlabeled, will by default be drawn
halfway between each major grid line.
You can also use the seq() function or the : operator to generate vectors for tick marks:
Search WWH ::




Custom Search