以下代码生成带有红色标记的图:
trace_0 <- rnorm(100, mean = 5)
trace_1 <- rnorm(100, mean = 0)
x <- c(1:100)
data <- data.frame(x, trace_0, trace_1)
plot_ly(data, x = ~x, y = ~trace_0, type = 'scatter', mode = 'markers',
marker = list(color='red'))
如果我尝试添加一行,也会出现不必要的红色标记:
plot_ly(data, x = ~x, y = ~trace_0, type = 'scatter', mode = 'markers',
marker = list(color='red'))%>%
add_trace(y = ~trace_1, mode = 'lines')
和plot_ly的投诉:
A marker object has been specified, but markers is not in the mode
Adding markers to the mode...
有人可以解释一下我在哪里出问题了吗?谢谢。
答案 0 :(得分:1)
这将为您提供想要的东西:
plot_ly(data, x = ~x) %>%
add_trace(y = ~trace_0, mode = 'markers', marker = list(color='red')) %>%
add_trace(y = ~trace_1, mode = 'lines')