简体   繁体   English

在ggvis中按组悬停工具提示

[英]Hover tooltip by group in ggvis

I want to be able to hover over a given point and be able to see information about that specific point and have it pop up larger than the others. 我希望能够将鼠标悬停在给定点上,并能够查看有关该特定点的信息,并使它弹出的幅度大于其他点。 That's done in the code below. 这是在下面的代码中完成的。

all_values <- function(x) {
  if(is.null(x)) return(NULL)
  paste0(names(x), ": ", format(x), collapse = "<br />")
}

iris %>% 
  ggvis(~Sepal.Length,~Petal.Length) %>%
    layer_points(size := 50, fill.hover := "yellow", size.hover := 200) %>% 
    add_tooltip(all_values, "hover")

Is there a way for all the points sharing the same Species variable as the selected point to have this highlighting applied to them as well? 是否有一种方法可以让所有与所选点共享相同“ Species变量的点也可以将突出显示应用于它们? In my real data, the fill and shape variables are being used to convey other information, so I need a way to quickly highlight an entire group. 在我的真实数据中,填充和形状变量用于传达其他信息,因此我需要一种快速突出显示整个组的方法。

这并不能真正回答您的问题,但是您是否考虑过使用fill属性对数据进行可视化分组?

layer_points(size := 50, fill = ~Species)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM