plotly-在哪里可以找到在plotly包中使用的默认调色板 [英] plotly - where can I find the default color palette used in plotly package

查看:67
本文介绍了plotly-在哪里可以找到在plotly包中使用的默认调色板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am primarily using the plotly package with r to plot my results. I would like to define the colors I use in my presentation document (tables, headings etc.) based on the default colors used in plotly. e.g. the colors used to fill the bars in a bar chart or the parts of a pie chart. Is there a way to find out the rgb or hex values?

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

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

I am looking for the rgb/hex values of the orange and the deep blue in the first pie chart.

推荐答案

我认为我为您提供了一个可行的解决方案.在plotly js和plotly R中,颜色是相同的.因此,我编写了一些JavaScript代码,在带有plotly.js的条形图中创建了6条迹线,然后将每个条的颜色打印到控制台和警报中.我为此创建了一个jsFiddle: https://jsfiddle.net/gcx3eoLw/

I think I have a working solution for you. In plotly js and plotly R the colors are the same. So I write a little javascript code that creates 6 traces in a barchart with plotly.js and print afterwards the colors of each bar to the console and in an alert. I created a jsFiddle for that: https://jsfiddle.net/gcx3eoLw/

所以前6种颜色是:

#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

希望有帮助:-)

从2020年起根据Despe1990的评论进行自从plotly 4(在python和R中可能?在plotly js中看不到调色板的变化)以来,前三种默认颜色已更改:#636efa,#ef553b和#00cc96

Edit from 2020 by comment of Despe1990: Since plotly 4 (in python and R maybe? I cannot see changes of color palette in plotly js) the first 3 default colors have changed: #636efa, #ef553b and #00cc96

这篇关于plotly-在哪里可以找到在plotly包中使用的默认调色板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆