title: How to add a plot name on the top left corner of the plot in R?
body: <p>I have two dataframes <code>df1</code> and <code>df2</code> as follows:</p>
  
  <pre><code>&gt; df1
               dateTime value
  1 2018-06-27 00:00:01     6
  2 2018-06-27 00:00:02     2
  3 2018-06-27 00:00:03     3
  4 2018-06-27 00:00:04     1
  &gt; df2
               dateTime value
  1 2018-06-27 00:00:01     3
  2 2018-06-27 00:00:02     8
  3 2018-06-27 00:00:03     4
  4 2018-06-27 00:00:04     5
  </code></pre>
  
  <p>I want to plot these dataframes in just one diagram, split them to two different plots with same <code>x</code> axis and add their names to the top left corner of their plots. Note that <code>dateTime</code> is a <code>POSIXct</code> object. Here is the code:</p>
  
  <pre><code>library(grid)
  library(dplyr)
  
  plot1 &lt;- df1 %&gt;%
    select(dateTime, value) %&gt;%
    ggplot() +
    geom_point(data = df1, aes(dateTime, value)) +
    geom_line(data = df1, aes(x = dateTime, y = value), color = 'green') +
    geom_text(aes(x = df1$dateTime[1], y = df1$value[1], label = "X Data"), color = "red", size = 7) +
    theme(axis.text=element_text(size = 14), axis.title=element_text(size = 14),
          axis.title.x=element_blank(),
          axis.text.x=element_blank(),
          axis.ticks.x=element_blank())
  
  plot2 &lt;- df2 %&gt;%
    select(dateTime, value) %&gt;%
    ggplot() +
    geom_point(data = df2, aes(dateTime, value)) + 
    geom_line(data = df2, aes(x = dateTime, y = value), color = 'red') +
    xlab("dateTime") +
    geom_text(aes(x = df2$dateTime[1], y = df2$value[1]+5, label = "Y Data"), color = "green", size = 7) +
    theme(axis.text=element_text(size = 14), axis.title=element_text(size = 14))
  
  grid.newpage()
  grid.draw(rbind(ggplotGrob(plot1), ggplotGrob(plot2), size = "last"))
  </code></pre>
  
  <p>And the result is:</p>
  
  <p><a href="https://i.stack.imgur.com/ESLUI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ESLUI.png" alt="enter image description here"></a></p>
  
  <p>As you can see, <code>X Data</code> and <code>Y Data</code> are in the top left corner, but I really do not like to manually change the coordinates in <code>geom_text</code> to get the exact position which I want. Is there a better way to do that without changing the coordinates manually?</p>