plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.26k stars 2.55k forks source link

unlabel_rgb does not work on a list as it says in the docs #3054

Open simonm3 opened 3 years ago

simonm3 commented 3 years ago

The docs say "This function takes either an ‘rgb(a, b, c)’ color or a list of such colors" but a list fails.

windows 10, plotly 4.14.3

from plotly.colors import *
colorset = sequential.YlOrRd
print([unlabel_rgb(c) for c in colorset])
print(unlabel_rgb(colorset))

[(255.0, 255.0, 204.0), (255.0, 237.0, 160.0), (254.0, 217.0, 118.0), (254.0, 178.0, 76.0), (253.0, 141.0, 60.0), (252.0, 78.0, 42.0), (227.0, 26.0, 28.0), (189.0, 0.0, 38.0), (128.0, 0.0, 38.0)]

ValueError Traceback (most recent call last)

in 2 colorset = sequential.YlOrRd 3 print([unlabel_rgb(c) for c in colorset]) ----> 4 print(unlabel_rgb(colorset)) ~\Anaconda3\Lib\site-packages\_plotly_utils\colors\__init__.py in unlabel_rgb(colors) 741 str_num = str_num + char 742 else: --> 743 numbers.append(float(str_num)) 744 str_num = "" 745 return (numbers[0], numbers[1], numbers[2]) ValueError: could not convert string to float: ''
gvwilson commented 2 months ago

@LiamConnors @alexcjohnson is this a bug or a feature request?

alexcjohnson commented 2 months ago

Sure looks like a bug to me, should be a simple fix.