Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Add geom_text() to
your graph. It requires a mapping for x, y, and
the text itself. By setting vjust
(the vertical justification), it is possible to move the text above or
below the tops of the bars, as shown in Figure 3-22:
library(gcookbook)# For the data set# Below the topggplot(cabbage_exp,aes(x=interaction(Date,Cultivar),y=Weight))+geom_bar(stat="identity")+geom_text(aes(label=Weight),vjust=1.5,colour="white")# Above the topggplot(cabbage_exp,aes(x=interaction(Date,Cultivar),y=Weight))+geom_bar(stat="identity")+geom_text(aes(label=Weight),vjust=-0.2)