-->

How to change legend position of ggvis when using

2019-08-14 05:28发布

问题:

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)


标签: r ggvis