- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想自定义 plotly
图中的颜色。这对于连续变量和尺度来说效果很好,如 docs 所示。 :
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
如何正确执行此操作?
最佳答案
这不是一个 plotly 问题,而是 ColorBrewer(以及相关的 RColorBrewer
包)的设计功能。您会注意到,当您将颜色
分配给等于或超过三个级别的因素时,警告消失了,例如
plot_ly(iris, x = Petal.Length, y = Petal.Width,
color = cut(Sepal.Length, 3), colors = "Set1",
mode = "markers")
这是因为 ColorBrewer 的数据类的最小数量为 3(您可以从 http://colorbrewer2.org/ 中看到,其中不能选择少于 3 个类)。例如,在 ?brewer.pal
(plotly引用的函数)中,它特别指出
All the sequential palettes are available in variations from 3 different values up to 9 different values.
[...]
For qualitative palettes, the lowest number of distinct values available always is 3
由于 build_plotly()
(函数 plotly()
内部调用)总是调用 brewer.pal()
(参见第 474 行 here ) ,如果不重写 build_plotly()
函数以不调用少于 3 个数据类的 brewer.pal()
,则无法解决此问题。
同时,要关闭警告,请将绘图输出分配给一个对象,并将 print(object)
语句包装在 suppressWarnings()
中,如下所示:
plotly_plot <- plot_ly(iris, x = Petal.Length, y = Petal.Width,
color = Sepal.Length>6, colors = c("#132B43", "#56B1F7"),
mode = "markers")
suppressWarnings(print(plotly_plot))
关于r - 绘图中的自定义离散色阶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38740837/
如何在 Flutter 中使 slider 离散看起来像上图? slider discrete 最佳答案 使用 divisions Slider 的属性(property)小部件将其分成相等的部分,然
我正在创建一个带有颜色条的散点图 plt.scatter(X, Y, c=Z) plt.colorbar() plt.show() plt.close() 其中 X 和 Y 是 float 组,Z 是
我刚刚在 android studio 中发现了 seekbar 离散小部件,我发现它非常有用,但我不知道如何删除步骤指示器,或者用更合适的可绘制对象更改它们。 有人设法做到了吗? 这是我当前搜索栏的
问题 请注意以下问题:巫师可以创建和销毁 rune 。创建一个新的 rune 需要消耗与先前创建的 rune 数量成比例的法力。摧毁 rune 会恢复创建 rune 所用的法力。下面,我提出一个可能的
我正在尝试使用 ggplot2 中的 sf 和 geom_sf 制作 map ,其中一组点数据使用连续颜色比例(-1 到 1),一组线数据使用离散比例(a、b、c、d)着色。但是,当我在同一张 map
我正在尝试在具有连续状态(dim.= 20)和离散操作(3 个可能的操作)的环境中找到最佳策略。并且有一个特定的时刻:对于最佳策略,一个操作(称为“操作 0”)的选择频率应比其他两个操作高得多(频率约
仅使用 x-y 位置移动绘制圆弧的最佳方法是什么?例如,假设我想在点 (4,4) 处绘制一个半径为 4 的圆。让我们看看我的“抽屉”从 (4,0) 开始,每个方向的分辨率为 0.1 步。我将如何创建一
我正在使用一个使用广义加法模型的随机站点级效应来拟合一个模型,该模型在 mgcv 中实现。 R 包。我一直在使用函数 gam() 执行此操作但是,为了加快速度,我需要转到 bam()框架,与gam()
这个问题在这里已经有了答案: Make a line separated by group in bar chart (3 个答案) 关闭上个月。 我正在尝试使用 ggplot2 在条形图的每个条上
这个问题在这里已经有了答案: Make a line separated by group in bar chart (3 个答案) 关闭上个月。 我正在尝试使用 ggplot2 在条形图的每个条上
是否可以同时使用 Intel HD 4000 集成显卡和独立 GPU,OpenCL(或 CUDA)作为设备,CPU 作为主机?我想要一些代码在集成显卡上运行,而其他代码同时在我的 GPU 上运行。 最
我是一名优秀的程序员,十分优秀!