Using plotly
(adding solution from plotly
with primary and secondary y axis- It seems to be missing):
library(plotly) x <- seq(-2, 2, 0.05)y1 <- pnorm(x)y2 <- pnorm(x, 1, 1)df=cbind.data.frame(x,y1,y2) plot_ly(df) %>% add_trace(x=~x,y=~y1,name = 'Line 1',type = 'scatter',mode = 'lines+markers',connectgaps = TRUE) %>% add_trace(x=~x,y=~y2,name = 'Line 2',type = 'scatter',mode = 'lines+markers',connectgaps = TRUE,yaxis = "y2") %>% layout(title = 'Title', xaxis = list(title = "X-axis title"), yaxis2 = list(side = 'right', overlaying = "y", title = 'secondary y axis', showgrid = FALSE, zeroline = FALSE))
Screenshot from working demo: