R Plot.ly 带有许多符号的散点图颜色错误
R Plot.ly scatterplot color error with many symbols
这是我在 R 中看到的问题示例:
plot_ly(x=1:20,y=1:20,color=1:20,mode='markers')
正确给出:
但是,对于两种不同的符号类型,散点图会减少到 2 种颜色(悬停文本保留 20 种颜色)
plot_ly(x=1:20,y=1:20,color=1:20,mode='markers',symbol=c(rep(0,10),rep(1,10)))
给予:
我试过手动编辑调色板,但这也无济于事。有没有简单的解决方法?
您应该为此在 marker
参数中设置颜色。
plot_ly(x = 1:20, y = 1:20, mode = "markers", type = "scatter",
marker = list(symbol = c(rep(1,10), rep(3,10)),
color = colorRampPalette(c("green", "yellow", "red"))(20),
size = 18 # helps see the color better for the example
)
)
这是我在 R 中看到的问题示例:
plot_ly(x=1:20,y=1:20,color=1:20,mode='markers')
正确给出:
但是,对于两种不同的符号类型,散点图会减少到 2 种颜色(悬停文本保留 20 种颜色)
plot_ly(x=1:20,y=1:20,color=1:20,mode='markers',symbol=c(rep(0,10),rep(1,10)))
给予:
我试过手动编辑调色板,但这也无济于事。有没有简单的解决方法?
您应该为此在 marker
参数中设置颜色。
plot_ly(x = 1:20, y = 1:20, mode = "markers", type = "scatter",
marker = list(symbol = c(rep(1,10), rep(3,10)),
color = colorRampPalette(c("green", "yellow", "red"))(20),
size = 18 # helps see the color better for the example
)
)