Label placing in ggplot2 using geom_text function in R

I'm designing some graphs within a function with ggPlot2 geom_text. It is a sequence of five graphs and, in each one, I want to place my label (my text) in the top right position. The problem is that I will constantly change my N and Y values (according to and input interval). X and Y coordinates will change, and even be out of scale. So how do I make the label placement fixed, let's say in the top right, in my graph?

Here's my code

parte.mac <- subset(dados, subset = (dados$Especie == 'C.macelaria' & dados$Temp >= minima & dados$Temp <= maxima))
  mac <- qplot(Temp, Tempo, data = parte.mac, color = Especie, main = 'C.macelaria', geom = c("point", "line"), add = T) +
    stat_smooth(method = 'lm', level = 0.99, alpha = 0.5, aes(group=1), color = 'blue') +
    geom_text(x = maxima, y = mean(range(dados$Tempo)), label =, parse = TRUE)

Please, help


Echoing the comment by @jazzuro, could you provide us with (your) reproducible data by running (don't send anything confidential!)


and pasting that with your question.

In the absence of your exact data, I'll echo @baptiste with a simple example using the "faithful" data file of the Old Faithful geyser eruptions:

p <- qplot(x=eruptions, y=waiting, data=faithful)

and then here is one example of an annotation:

p + annotate("text", x=3, y=40, label="Group 1") + annotate("text", x=4.5, y=60, label="Group 2")

Below is a second example, using arguments such as "min" and "max" for placement of the annotations:

p + annotate("text", x=min(faithful$eruptions), y=min(faithful$waiting), label="Group 1") + annotate("text", x=max(faithful$eruptions), y=max(faithful$waiting), label="Group 2")

If this doesn't help, remember to dput your data and paste into your question.

Need Your Help

github can't access folder after push

git github repository push pull

I was working in a folder and can push/pull with github quite well. But now I'm trying to wrap this folder with another one, and after pushing the new folder to github I can't get access to the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.