Home > database >  using dygraph library in r to plot dual axis
using dygraph library in r to plot dual axis

Time:11-12

I am trying to plot two series at different scales on same plot with dygraph lib in r.

dygraph(data.frame(x = 1:10, y = runif(10),y2=runif(10)*100)) %>%
  dyAxis("y", valueRange = c(0, 1.5)) %>%
  dyAxis(runif(10)*100,name="y2", valueRange = c(0, 100)) %>%
  dyEvent(2, label = "test") %>%
  dyAnnotation(5, text = "A")

however, The plot does not fit the data with larger scale, I cannot figure out how to align the two axises. I suspect the option independentTicks in dyAxis() function does the trick but I cannot find how to use it in the documentation. Please help out with this. Best

CodePudding user response:

One way could be: We pass the named vector of the column with higher values to dySeries function: See here enter image description here

  • Related