Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Combining Scatterplot and Line Chart R Plotly (No Symbols on Line)

Hello, I just asked this question on stack overflow, but wondering if I might get a quicker response here.

I am using Plotly to visualize some data (below):

y1 <- rnorm(100, mean = 5)
y2 <- rnorm(100, mean = -5)
x <- c(1:100)

data <- data.frame(x, y1, y2)

I want to have two plots, a scatterplot for y1 (just markers), and a line plot for y2 (just line, no markers).

I have this working…

plot_ly(data, x = ~x, y = ~y1, name = 'symbol only', type = 'scatter', mode = 'markers') %>%
  add_trace(y = ~y2, name = 'line only', mode = 'lines',
             line = list(shape = 'spline', color = 'rgb(200, 12, 46)', width = 2))

However, I want to change the color and symbol of the markers in y1. When I do that, it adds markers to y2, which I do not want. How can I fix this?

plot_ly(data, x = ~x, y = ~y1, name = 'symbol only', type = 'scatter', mode = 'markers',
             symbol = 8) %>%
  add_trace(y = ~y2, name = 'line only (why markers added?)', mode = 'lines',
             line = list(shape = 'spline', color = 'rgb(200, 12, 46)', width = 2))