You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Plotly doesn't recognise modern RGB syntax (+ other unexpected behaviour) #4824
Plotly does not support modernrgb(R G B / A) CSS syntax. It seems to prefer the legacy versions of rgb(R, G, B) or rgba(R, G, B, A), but it still does not support these completely (as can be seen in the examples bellow).
This can be experienced in a few different ways, such as:
The alpha/opacity value is ignored by Plotly even when using the legacy rgb(R, G, B, A) syntax.
>>> go.Figure().add_trace(go.Scatter(x=[1,2], y=[1,2], line_color="rgb(0 0 0)")).show()
Traceback (most recent call last):
...
ValueError:
Invalid value of type 'builtins.str' received for the 'color' property of scatter.line
Received value: 'rgb(0 0 0)'
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
...
The same can be seen when using the modern rgb syntax with an alpha-channel
>>> go.Figure().add_trace(go.Scatter(x=[1,2], y=[1,2], line_color="rgb(0 0 0 / 0.5)")).show()
Same exception as above
Throughout the docs (e.g., 1, 2, 3) Plotly seems to imply that any valid CSS colors are accepted. Maybe this was never the plan? If so, maybe we should at least document this a bit better and make it more explicit which values are accepted. Also, if this is the case, should Plotly raise an exception for examples 1. and 2., since the opacity values seem to be unexpectedly dropped in the background?
Thanks in advance, and happy to share more context where needed 🚀
Thanks for the report! There are some regex patterns that control what values are allowed for colors in plotly.py. Those feed into plotly.js where we use a library called TinyColor to handle adding them to plot elements. I'll look into if it's possible to include those other versions of rgb calls that you mentioned. Additionally, we had a request in plotly/plotly.js#7389 to make it possible to use the alpha channel with hex colors that I'll look into.
Activity
camdecoster commentedon Aug 13, 2025
Thanks for the report! There are some regex patterns that control what values are allowed for colors in plotly.py. Those feed into plotly.js where we use a library called TinyColor to handle adding them to plot elements. I'll look into if it's possible to include those other versions of rgb calls that you mentioned. Additionally, we had a request in plotly/plotly.js#7389 to make it possible to use the alpha channel with hex colors that I'll look into.
emilykl commentedon Jul 27, 2026
Addressed by the upgrade to plotly.js v4.0.0 in #5673; we'll close this issue once the next major plotly.py version is released.