Search code examples
rplotcolorsplotly

Where can I find the default color palette used in the plotly package


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.


Solution

  • 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