plotly - 我在哪里可以找到 plotly 包中使用的默认调色板

plotly - where can I find the default color palette used in plotly package

我主要使用带有 r 的 plotly 包来绘制我的结果。我想根据 plotly 中使用的默认颜色来定义我在演示文档(表格、标题等)中使用的颜色。例如用于填充条形图中的条形或饼图的各个部分的颜色。有没有办法找出 rgb 或 hex 值?

在此处查看示例: https://plot.ly/r/pie-charts/

我正在寻找第一个饼图中橙色和深蓝色的 rgb/hex 值。

我想我有一个适合您的解决方案。在 plotly js 和 plotly R 中,颜色是相同的。因此,我编写了一些 javascript 代码,使用 plotly.js 在条形图中创建 6 条轨迹,然后将每个条形的颜色打印到控制台和警报中。 我为此创建了一个 jsFiddle:https://jsfiddle.net/gcx3eoLw/

所以第一种颜色是:

#1f77b4 or rgb(31, 119, 180)  // muted blue
#ff7f0e or rgb(255, 127, 14)  // safety orange
#2ca02c or rgb(44, 160, 44)   // cooked asparagus green
#d62728 or rgb(214, 39, 40)   // brick red
#9467bd or rgb(148, 103, 189) // muted purple
#8c564b or rgb(140, 86, 75)   // chestnut brown
#e377c2 or rgb(227, 119, 194)
#7f7f7f or rgb(127, 127, 127)
#bcbd22 or rgb(188, 189, 34)
#17becf or rgb(23, 190, 207)

希望对您有所帮助:-)

根据 Despe1990 的评论从 2020 年开始编辑: 由于 plotly 4(可能在 python 和 R 中?我在 plotly js 中看不到调色板的变化)前 3 个默认颜色已更改:#636efa、#ef553b 和 #00cc96