Search code examples
javascriptrhighchartsr-highcharter

How to add vertical (and horizontal) line in highcharts scatter plot


highcharts failed to add vertical line in the scatter plot. Below is one such example -

library(highcharter)

Data = data.frame(x = round(rnorm(20) * 100, 2), y = round(rnorm(20) * 100, 2), z = letters[1:20])
hchart(Data, "bubble", hcaes(x, y)) %>%
        hc_yAxis(plotLines = list(value = 0))

This plots nothing. Can someone points me towards the right direction?


Solution

  • Change type = "bubble" to type = "scatter" and hc_yAxis as below

    hchart(Data, "scatter", hcaes(x, y)) %>%
      hc_yAxis(
        plotLines = list(
          list(color = "#252525",
               width = 2,
               value = 0)
        )
      )