Could we access plotly.js default colors in plotly.py ?
See original GitHub issueI like very much plotly’s default color scale. However, I am not aware of an official way to reproduce it when I want multiple traces to be of the same color. For now I use the explicit list from https://stackoverflow.com/a/44727682, which I have coded into a function (see below). Is there a recommended way to enforce two traces to be of the same color ? Would you consider including in plotly.py the default color scale ? Thanks
from itertools import cycle
def plotly_color_map(names):
# From https://stackoverflow.com/a/44727682
plotly_colors = cycle(['#1f77b4', # muted blue
'#ff7f0e', # safety orange
'#2ca02c', # cooked asparagus green
'#d62728', # brick red
'#9467bd', # muted purple
'#8c564b', # chestnut brown
'#e377c2', # raspberry yogurt pink
'#7f7f7f', # middle gray
'#bcbd22', # curry yellow-green
'#17becf' # blue-teal
])
return dict(zip(names, plotly_colors))
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to get Plotly.js default colors list? - Stack Overflow
According to the source code, the default color list is: '#1f77b4', // muted blue '#ff7f0e', // safety orange '#2ca02c', // cooked asparagus ...
Read more >Discrete colors in Python - Plotly
This page is about using color to represent categorical data using discrete colors, but Plotly can also represent continuous values with color.
Read more >Introducing plotly.py 3.0.0 | by Plotly | Plotly | Medium
plotly.js graphs are declarative. This means that every aspect of the charts (the colors of the bars, the axes grid lines, the position...
Read more >Python Plotly: How to set up a color palette? - GeeksforGeeks
In this article, we will discuss how to explicitly set up a color sequence/color palette in plotly. Generally, we use built-in color ......
Read more >plotly package — 5.11.0 documentation - Plotly Help Center
Plotly's Python API allows users to programmatically access Plotly's server resources ... For example, to specify the annotation text “example” you can pass ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Turns out this has been in plotly.py all along, but I just learned about it today 🙂
Can you confirm that this is what you were looking for?
Hello @jmmease, yes certainly I could import the colorscale from the
colorlover
package, that would already be more generic than copying/pasting stackoverflow.I like the
colorway
layout option, thanks for sharing.Finally, I would appreciate to simplify the task of giving same colors to traces that have identical names. Would you have recommendations on how to make the below shorter ?