Graphics Reference
In-Depth Information
Chapter7.Annotations
Displaying just your data usually isn't enough—there's all sorts of other information that can help
the viewer interpret the data. In addition to the standard repertoire of axis labels, tick marks, and
legends, you can also add individual graphical or text elements to your plot. These can be used
to add extra contextual information, highlight an area of the plot, or add some descriptive text
about the data.
Adding Text Annotations
Problem
You want to add a text annotation to a plot.
Solution
Use annotate() and a text geom ( Figure 7-1 ):
p <- ggplot(faithful, aes(x = eruptions, y = waiting)) + geom_point()
p + annotate( "text" , x = 3 , y = 48 , label = "Group 1" ) +
annotate( "text" , x = 4.5 , y = 66 , label = "Group 2" )
Search WWH ::




Custom Search