刚开始使用Shiny。我问你:是否可以在ggvis图中添加由截距和斜率特征的单条线?
例如,使用geom_abline在ggplot2中。
我感兴趣的代码位于server.R文件中,位于https://github.com/wch/movies,并涉及此示例http://shiny.rstudio.com/gallery/movie-explorer.html。
这是绘制线条的一种方法。
例如,使用geom_abline在ggplot2中。
我感兴趣的代码位于server.R文件中,位于https://github.com/wch/movies,并涉及此示例http://shiny.rstudio.com/gallery/movie-explorer.html。
这是绘制线条的一种方法。
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()
但我希望您能在上面链接提到的现有ggvis图表上绘制它。
这里应该添加一些代码:
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)
})