HI,
How can I extend the regression line in such a way that it touches the axes?
require(plotly)
set.seed(100)
dt=data.frame(
a=runif(10,0,1),
b=runif(10,1,10))
ax <- list(
title = "Measured",
zeroline = TRUE,
showline = TRUE,
showticklabels = TRUE,
mirror = "ticks",
showgrid = FALSE,
range = c(0,1))
ay <- list(
title = "Synthetic",
zeroline = TRUE,
showline = TRUE,
showticklabels = TRUE,
mirror = "ticks",
showgrid = FALSE,
range = c(1,10))
lm_zero=lm(b~a, data = dt)
plot_ly(dt, x = ~a, y = ~b) %>%
add_trace(type = 'scatter',mode = 'markers') %>%
layout( xaxis = ax,yaxis = ay)%>%
config(mathjax = "cdn") %>%
add_lines(x =~a, y = fitted(lm_zero),line = list(color = 'black',dash = 'line'))