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.
Color Sequences in Plotly ExpressBy default, Plotly Express will use the color sequence from the active template's layout. colorway attribute, and the default active template is plotly which uses the plotly color sequence. You can choose any of the following built-in qualitative color sequences from the px. colors.
Answer: Red, Orange, Yellow, Green, Blue, Indigo and Violet.
plotly is an R package for creating interactive web-based graphs via the open source JavaScript graphing library plotly. js . As of version 2.0 (November 17, 2015), graphs created with the plotly R package are rendered locally through the htmlwidgets framework.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With