Annotating axis in ggplot2
I am looking for the way to annotate axis in ggplot2. The example of the problem can be found here: http://learnr.wordpress.com/2009/09/24/ggplot2-back-to-back-bar-charts.
The y axis of the chart (example graph in the link) has an annotation: (million euro). Is there a way to create such types of annotations in ggplot2? Looking at the documentation there is no obvious way, since the ggplot does not explicitly let you put objects outside plotting area. But maybe there is some workaround?
One of the possible workaro开发者_JAVA百科unds I thought about is using scales:
data=data.frame(x=1:10,y=1:10)
qplot(x=x,y=y,data=data)+scale_y_continuous(breaks=10.1,label="Millions")
But then how do I remove the tick? And it seems that since ggplot does not support multiple scales, I will need to grab the output of the scale_y_continuous, when it calculates the scales automaticaly and then add my custom break and label by hand. Maybe there is a better way?
Maybe grid.text()
:
grid.text("label", x = unit(xpos, "npc"), y = unit(ypos, "npc"))
with appropriate values for xpos
and ypos
.
精彩评论