I just started using plotly in R, and I've made a plot like this
with a syntax like this:
maximum <- rnorm(30, mean = 20)
datasource <- rnorm(30, mean = 15)
minimum <- rnorm(30, mean = 10)
x <- c(1:30)
data <- data.frame(x,datasource,maximum,minimum)
fig <- plot_ly(data, x = ~x, y = ~datasource, name = 'trace 1', type = 'scatter', mode = 'lines+markers', marker = list(size = 10))
fig <- fig %>% add_trace(y = ~maximum, name = 'maximum', mode = 'markers', marker = list(size = 10))
fig <- fig %>% add_trace(y = ~minimum, name = 'minimum', mode = 'markers', marker = list(size = 10))
fig <- fig %>% layout(title = "XBAR CHART",
xaxis = list(title = "ID"),
yaxis = list (title = "Measurement Value (mm)"))
fig
I want to add a line connecting the minimum and maximum markers like the following.

I've been trying but haven't found the solution.
I hope I find a solution here. thanks
calculate the points that defined the lines
add them to the layout