title: Overlay legend on interactive ggvis plot
body: <p>I would like to put my legend inside the plot as <a href="https://stackoverflow.com/questions/30949540/ggvis-add-legend-with-multiple-data-and-position-legend-inside-graph">answered in this question</a>, but for an interactive plot.</p>
  
  <p>In the first code chunk the legend disappears off the plot, but when I remove the interaction it works.</p>
  
  <pre><code>library(ggvis)
  library(dplyr)
  
  # With drop down list it doesn't work
  mtcars %&gt;% 
    ggvis(x = ~wt, y = input_select(c("Miles per gallon" = "mpg", "Horse power" = "hp", "Displacement"="disp", "Carbohydrates" = "carb"), map = as.name, selected = "mpg", label = "Variables"), fill=~cyl) %&gt;% 
    layer_points() %&gt;% 
    add_relative_scales() %&gt;%
    add_legend("fill", title = "Cylinders",
               properties = legend_props(
                 legend = list(
                   x = scaled_value("x_rel", 0.8),
                   y = scaled_value("y_rel", 1)
                 )))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8Cz2c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Cz2c.png" alt="enter image description here"></a></p>
  
  <pre><code># Remove interaction and it works
  mtcars %&gt;% 
    ggvis(x = ~wt, y = ~mpg, fill = ~cyl) %&gt;% 
    layer_points() %&gt;% 
    add_relative_scales() %&gt;%
    add_legend("fill", title = "Cylinders",
               properties = legend_props(
                 legend = list(
                   x = scaled_value("x_rel", 0.8),
                   y = scaled_value("y_rel", 1)
                 )))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rjBl5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjBl5.png" alt="enter image description here"></a></p>
  
  <p>How can I overlay the legend in an interactive plot?</p>