R plotly lines like abline but with add_trace


How do you use add_trace (or some other call or layout) to had horizontal and vertical lines without bounds? e.g x=c(20,20), y = (-Inf,Inf). I can see how to do this with ggplotly(), but I was hoping to do so without re-writing calls that used add_trace().

In R this request is similar to what abline() does. Any ideas?


1 Like

I concluded from ggplotly that there may not be an elegant way to do this. ggplotly essentially just uses the data ranges/extent to draw the line as a segment, and when you are using it for something like an “upper control line” looks weird if the user zooms out.