How to change legend position of ggvis when using tooltip as well?

折月煮酒 提交于 2019-12-13 17:16:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!