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

南楼画角 提交于 2021-02-18 21:13:56

问题


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?

see the example here: https://plot.ly/r/pie-charts/

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


回答1:


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/

So the 6 first colors are:

#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

Hope it helps:-)

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



来源:https://stackoverflow.com/questions/41761654/plotly-where-can-i-find-the-default-color-palette-used-in-plotly-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!