我想使用highcharter
包绘制一个大的散点图,但只允许鼠标悬停在几个异常值上。有没有办法在一个系列上启用mouseTracking而不是另一个系列?
df <- data.frame( x = rnorm(1000), y = rnorm(1000) )
df$sig <- ifelse( abs(df$x) > 2, "signif", "not")
library(highcharter)
hc <- highchart() %>%
hc_add_series_df(df, type = "scatter", group=sig)
现在我只能在所有点上禁用鼠标悬停,但hc_plotOptions
说明了使用系列数组的内容吗?
hc_plotOptions(hc, scatter = list( enableMouseTracking= FALSE ))
答案 0 :(得分:2)
有很多方法可以做你想要的。
我认为最简单的就是使用:
hchart(df, "scatter", hcaes(x, y, group = sig), enableMouseTracking = c(FALSE, TRUE))
(注意这是highcharter的开发版本。)
与...相同:
highchart() %>%
hc_add_series(data = df %>% filter(sig == "not"), type = "scatter", enableMouseTracking = FALSE) %>%
hc_add_series(data = df %>% filter(sig == "signif"), type = "scatter", enableMouseTracking = TRUE)
或者
highchart() %>%
hc_add_series(data = list_parse(df %>% filter(sig == "not")), type = "scatter", enableMouseTracking = FALSE) %>%
hc_add_series(data = list_parse(df %>% filter(sig == "signif")), type = "scatter", enableMouseTracking = TRUE)