title: ggvis - add_legend with multiple data and position legend inside graph
body: <p>I'm trying to add legends with arbitrary text in a ggvis plot using data from different dataframes. I have tried using <code>add_legend()</code> but I have not idea about what parameters to use. Using <code>plot()</code> is very simple using the <code>legend()</code> function but it has been very hard to find a way to do it using <code>ggvis()</code></p>
  
  <p>Here is a simple example of what I have using <code>plot()</code>:</p>
  
  <pre><code>df1 = data.frame(x = sample(1:10), y = sample(1:10))
  df2 = data.frame(x = 1:10, y = 1:10)
  df3 = data.frame(x = 1:10, y = sqrt(1:10))
  
  plot(df1)
  lines(df2$x, df2$y, col = "red")
  lines(df3$x, df3$y, col = "green")
  legend("topleft", c("Data 2","Data 3"), lty = 1, col = c("red","green"))
  </code></pre>
  
  <p>Now, using <code>ggvis()</code> I can plot the points and the lines from different datasets but I can not find a way to put the legends using <code>add_legend()</code>, Here is the code using <code>ggvis()</code>:</p>
  
  <pre><code>df1 %&gt;% ggvis(x=~x,y=~y) %&gt;% layer_points() %&gt;% 
  layer_paths(x=~x,y=~y,data = df2, stroke := "red") %&gt;% 
  layer_paths(x=~x,y=~y,data = df3, stroke := "green") 
  </code></pre>
  
  <p>I will really appreciate any help.</p>
  
  <p>Thank you.</p>
  
  <p>Edited:</p>
  
  <p>This a sample code using only one data frame and <code>plot()</code></p>
  
  <pre><code>df = data.frame(x = sample(1:10), y = sample(1:10), x2 = 1:10, y2 = 1:10, y3 = sqrt(1:10) )
  plot(df[,c("x","y")])
  lines(df$x2, df$y2, col = "red")
  lines(df$x2, df$y3, col = "green")
  legend("topleft", c("Data 2","Data 3"), lty = 1, col = c("red","green"))
  </code></pre>