Graphics Reference
In-Depth Information
Figure 7-11. Line segments with arrow heads
The default angle is 30, and the default length of the arrowhead lines is 0.2 inches.
If one or both axes are discrete, the xand ypositions are such that the categorical items have
coordinate values 1, 2, 3, and so on.
See Also
For more information about the parameters for drawing arrows, load the grid package and see
?arrow .
Adding a Shaded Rectangle
Problem
You want to add a shaded region.
Solution
Use annotate("rect") ( Figure 7-12 ):
library(gcookbook) # For the data set
p <- ggplot(subset(climate, Source == "Berkeley" ), aes(x = Year, y = Anomaly10y)) +
geom_line()
p + annotate( "rect" , xmin = 1950 , xmax = 1980 , ymin = -1 , ymax = 1 , alpha = .1 ,
fill = "blue" )
Search WWH ::




Custom Search