I'm trying to draw a vertical line on a ggplotly object, but I get this weird Error:
Error in FUN(X[[i]], ...) :
'options' must be a fully named list, or have no names (NULL)
Here is a reprex for ggplot and plotly:
library(ggplot2)
library(plotly)
set.seed(42)
# ggplotly version
ggplotly(
ggplot(data.frame(x = rnorm(100), y = rnorm(100)), aes(x=x, y=y)) +
geom_point()
)%>%
layout(
shapes = list(
type = "line",
line = list(color = "gray", dash = "dot"),
x0 = 1,
x1 = 1,
y0 = 0,
y1 = 1,
yref = "paper"
)
)
# plotly version
plot_ly(x=~rnorm(100), y=~rnorm(100)) %>%
layout(
shapes = list(
type = "line",
line = list(color = "gray", dash = "dot"),
x0 = 1,
x1 = 1,
y0 = 0,
y1 = 1,
yref = "paper"
)
)
Any idea why the first example returns an error?