12

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.

eylemyap
  • 189
  • 2
  • 2
  • 10
  • What do u mean exactly? Do you mean the color of the curves/traces or which colors of plot do you mean? – phil Jan 20 '17 at 14:35
  • 1
    sorry for not being specific: i meant the fill-colors of the bars in the barplot or the colors used to fill the piecharts. – eylemyap Jan 20 '17 at 14:53
  • this might help (I think it's qualitative pair): https://plot.ly/ipython-notebooks/color-scales/ – MLavoie Jan 20 '17 at 15:50

1 Answers1

21

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 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
#e377c2 or rgb(227, 119, 194)
#7f7f7f or rgb(127, 127, 127)
#bcbd22 or rgb(188, 189, 34)
#17becf or rgb(23, 190, 207)

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

phil
  • 1,289
  • 1
  • 15
  • 24
  • 1
    those are exactly what I was looking for. thanks a lot! my programming skills are not that advanced. however following your line of thought I used the "inspect" option of google chrome and found this: rgb(255, 127, 14)! – eylemyap Jan 20 '17 at 16:36
  • a good oportunity too:-) – phil Jan 20 '17 at 16:50
  • The default palette has changed with the most recent versions. Would be nice to have an update on this. Thanks – Despe1990 Mar 12 '20 at 12:06
  • @Despe1990 I cannot see any changes in the palette. The provided jsfiddle uses the latest version of plotly.js and the colors are the same as written here. Also not found any changes in changelog to this: https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md – phil Mar 19 '20 at 07:47
  • with plotly 4 installed the first 3 default colours have changed: #636efa, #ef553b and #00cc96 – Despe1990 Apr 01 '20 at 08:47
  • 2
    Here is the plotly4 default colors (e.g. for multiple scatter traces): ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"] – Shay Ben-Sasson Feb 03 '21 at 14:09
  • @ShayBen-Sasson Thanks for providing some further colors. I added the 4 last colors also to my answer to have them complete there – phil Jul 15 '21 at 13:00