我想自定义plotly
图中的颜色。按照文档所述,对于连续变量和尺度,这是有效的:
library(plotly)
plot_ly(iris, x = Petal.Length, y = Petal.Width,
color = Sepal.Length, colors = c("#132B43", "#56B1F7"),
mode = "markers")
如果我将参数更改为离散颜色(字符或因子),代码仍然能够运行但会出现警告:
> plot_ly(iris, x = Petal.Length, y = Petal.Width,
color = Sepal.Length>6, colors = c("#132B43", "#56B1F7"),
mode = "markers")
Warning message:
In RColorBrewer::brewer.pal(N, "Set2") :
minimal value for n is 3, returning requested palette with 3 different levels
我要如何正确地做这件事?