![](/img/trans.png)
[英]Dropdown menu for changing the color attribute of data in scatter plot (Plotly R)
[英]Issue changing marker color in R plotly scatter plot
以下代码生成带有红色标记的图:
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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.