相关疑难解决方法(0)

在图中定制离散色标

我想自定义plotly绘图中的颜色.这适用于连续变量和按照文档进行缩放:

library(plotly)

plot_ly(iris, x = Petal.Length, y = Petal.Width,
             color = Sepal.Length, colors = c("#132B43", "#56B1F7"),
             mode = "markers")
Run Code Online (Sandbox Code Playgroud)

但是,如果我将参数设置为离散颜色(字符或因子),这仍然有效,但会发出警告:

> 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
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

r plotly

1
推荐指数
1
解决办法
5615
查看次数

标签 统计

plotly ×1

r ×1