Just getting start with Shiny. I ask you: is it possible to add single lines characterized by intercept and slope to ggvis plot?
For example with ggplot2 using geom_abline.
The code that i'm interested to debat is in the server.R file located at https://github.com/wch/movies and refers to this example http://shiny.rstudio.com/gallery/movie-explorer.html.
This is a way to draw a line
x_min <- 0
x_max <- 10
m <- 1
b <- 5
x <- c(x_min, x_max)
y <- m*x + b
df <- data.frame(x = x, y = y)
df %>% ggvis(x = ~x, y = ~y) %>% layer_lines()
but i'm interested to draw it OVER an existent ggvis plot, that of link above.
I should add some code here:
movies %>%
ggvis(x = xvar, y = yvar) %>%
layer_points(size := 50, size.hover := 200,
fillOpacity := 0.2, fillOpacity.hover := 0.5,
stroke = ~has_oscar, key := ~ID) %>%
add_tooltip(movie_tooltip, "hover") %>%
add_axis("x", title = xvar_name) %>%
add_axis("y", title = yvar_name) %>%
add_legend("stroke", title = "Won Oscar", values = c("Yes", "No")) %>%
scale_nominal("stroke", domain = c("Yes", "No"),
range = c("orange", "#aaa")) %>%
set_options(width = 500, height = 500)
})
I'm interested in a solution that introspects the
vis
to get the domain.Here's what I came up with (which also doesn't do that):
I found the solution, i thank a dear friend for this:
The coordinates refer to the usual example http://shiny.rstudio.com/gallery/movie-explorer.html.