highcharts 向R中的Highcharter散点图中的点添加抖动或透明度

vsdwdz23  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(242)

我正在弄清楚如何使用Highcharter库在R中放置抖动参数或增加一些透明度到散点图中。我发现大部分代码都与Javascript有关。但我正在寻找额外的参数来放置,这样我的点就不会被过度绘制。

下面是代码:

library(highcharter)
library(tidyverse)

clist %>%
  hchart("scatter", hcaes(x = completion_rate, y = synergy_scores, group = course_code)) %>% 
           hc_xAxis(title = list(text = "Completion rate")) %>%
          hc_yAxis(title = list(text = "Synergy score")) %>% 
  hc_tooltip(pointFormat ="<b> Synergy score: </b> {point.y} <br>") %>% 
  hc_title(text = "Courses with positive and negative Synergy scores")

数据:here
任何帮助都是感激不尽的。

2nc8po8w

2nc8po8w1#

你可以使用states,这意味着当你高亮显示一个点时,其他点opacity会更低。

library(highcharter)
library(tidyverse)

clist %>%
  hchart("scatter", hcaes(x = completion_rate, y = synergy_scores, group = course_code)) %>% 
  hc_xAxis(title = list(text = "Completion rate")) %>%
  hc_yAxis(title = list(text = "Synergy score")) %>% 
  hc_tooltip(pointFormat ="<b> Synergy score: </b> {point.y} <br>") %>% 
  hc_title(text = "Courses with positive and negative Synergy scores") %>%
  hc_plotOptions(series = list(states = list(inactive = list(opacity = 0.5))))

输出量:

您可以看到,其他点的透明度低于亮显的点。

相关问题