Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

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?


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.