以下代码生成一个带有红色标记的图:
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...
有人可以解释一下我哪里出错了吗?谢谢。
这会给你你想要的:
plot_ly(data, x = ~x) %>%
add_trace(y = ~trace_0, mode = 'markers', marker = list(color='red')) %>%
add_trace(y = ~trace_1, mode = 'lines')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句