问题
This thread shows how to change the position of the legend in a ggvis object. However, if tooltips are added as well, the legend disappears.
library(ggvis)
data(mtcars)
mtcars %>%
ggvis(x = ~wt, y = ~mpg, fill = ~cyl) %>%
layer_points() %>%
add_legend(
"fill",
properties = legend_props(
legend = list(
x = scaled_value("x", 3.25),
y = scaled_value("y", 40)
)
)
) %>%
add_tooltip(function(df) df$wt)
Any idea how to prevent this?
回答1:
This is a know issue, you can try adding the below at the end of your code as a workaround:
... %>% set_options(duration = 0)
来源:https://stackoverflow.com/questions/35452191/how-to-change-legend-position-of-ggvis-when-using-tooltip-as-well