JW52
1
Hello,
I’ve tried to generate a scatter plot with markers and lines as mode arguments:
st ← c(1,2,3,4,5);nd ← c(1,2,3,4,5);rd ← c(-1,-2,-3,-4,-5);th ← c(1,2,3,4,5)
plot_ly(x = st, y = nd, type = “scatter”, mode = “lines”, name = “line”,
line = list(color = “green”))%>%
add_trace(x = rd, y = th, type = “scatter”, mode = “markers”, name = “markers”,
marker = list(color = “red”))
Default colours work fine, adjustment results in this:
A line object has been specified, but lines is not in the mode Adding lines to the mode…<<

Thanks for any tips.
JW52
2
Re-freshing the topic - I found the same problem for histograms, when the kernel density is added.
bcd
3
Hey @JW52
There are two ways you can do this. (1) add inherit = F
to the 2nd trace:
st <- c(1,2,3,4,5)
nd <- c(1,2,3,4,5)
rd <- c(-1,-2,-3,-4,-5)
th <- c(1,2,3,4,5)
plot_ly(x = st, y = nd, type = "scatter", mode = "lines", name = "line",
line = list(color = "green"))%>%
add_trace(x = rd, y = th, type = "scatter", mode = "markers", name = "markers",
marker = list(color = "red"), inherit = F)
or (2):
plot_ly() %>%
add_trace(x = st, y = nd, type = "scatter", mode = "lines", name = "line",
line = list(color = "green"))%>%
add_trace(x = rd, y = th, type = "scatter", mode = "markers", name = "markers",
marker = list(color = "red"))