@@ -180,13 +180,16 @@ def validate_colors(colors, colors_list=None):
180180 """
181181 Validates color(s) and returns an error for invalid color(s)
182182
183- :param (list) colors_list: whether a singleton color or a list/tuple of
183+ :param (str|tuple|list) colors: either a plotly scale name, an rgb or hex
184+ color, a color tuple or a list/tuple of colors
185+ :param (list) colors_list: whether a single color or a list/tuple of
184186 colors is inputted, all the color types are appended to colors_list
185187 so they can be easily iterated through for validation
186188 """
187189 if colors_list is None :
188190 colors_list = []
189191
192+ # if colors is a single color, put into colors_list
190193 if isinstance (colors , str ):
191194 if colors in PLOTLY_SCALES :
192195 return
@@ -250,6 +253,8 @@ def convert_colors_to_same_type(colors, colortype='rgb', scale=None,
250253 be coverted to the selected colortype. If colors is None, then there is an
251254 option to return portion of the DEFAULT_PLOTLY_COLORS
252255
256+ :param (str|tuple|list) colors: either a plotly scale name, an rgb or hex
257+ color, a color tuple or a list/tuple of colors
253258 :param (list) colors_list: see docs for validate_colors()
254259 :param (list) scale: see docs for validate_scale_values()
255260
@@ -327,42 +332,40 @@ def convert_colors_to_same_type(colors, colortype='rgb', scale=None,
327332 'for your colortype variable.' )
328333
329334
330- def convert_dict_colors_to_same_type (colors , colortype = 'rgb' ):
335+ def convert_dict_colors_to_same_type (colors_dict , colortype = 'rgb' ):
331336 """
332- Converts color(s) to the specified color type
337+ Converts a colors in a dictioanry of colors to the specified color type
333338
334- Takes a single color or an iterable of colors and outputs a list of the
335- color(s) converted all to an rgb or tuple color type. If colors is a
336- Plotly Scale name then the cooresponding colorscale will be outputted
339+ :param (dict) colors_dict: a dictioanry whose values are single colors
337340 """
338- for key in colors :
339- if '#' in colors [key ]:
340- colors [key ] = color_parser (
341- colors [key ], hex_to_rgb
341+ for key in colors_dict :
342+ if '#' in colors_dict [key ]:
343+ colors_dict [key ] = color_parser (
344+ colors_dict [key ], hex_to_rgb
342345 )
343- colors [key ] = color_parser (
344- colors [key ], label_rgb
346+ colors_dict [key ] = color_parser (
347+ colors_dict [key ], label_rgb
345348 )
346349
347- elif isinstance (colors [key ], tuple ):
348- colors [key ] = color_parser (
349- colors [key ], convert_to_RGB_255
350+ elif isinstance (colors_dict [key ], tuple ):
351+ colors_dict [key ] = color_parser (
352+ colors_dict [key ], convert_to_RGB_255
350353 )
351- colors [key ] = color_parser (
352- colors [key ], label_rgb
354+ colors_dict [key ] = color_parser (
355+ colors_dict [key ], label_rgb
353356 )
354357
355358 if colortype == 'rgb' :
356- return colors
359+ return colors_dict
357360 elif colortype == 'tuple' :
358- for key in colors :
359- colors [key ] = color_parser (
360- colors [key ], unlabel_rgb
361+ for key in colors_dict :
362+ colors_dict [key ] = color_parser (
363+ colors_dict [key ], unlabel_rgb
361364 )
362- colors [key ] = color_parser (
363- colors [key ], unconvert_from_RGB_255
365+ colors_dict [key ] = color_parser (
366+ colors_dict [key ], unconvert_from_RGB_255
364367 )
365- return colors
368+ return colors_dict
366369 else :
367370 raise exceptions .PlotlyError ('You must select either rgb or tuple '
368371 'for your colortype variable.' )
@@ -406,6 +409,8 @@ def make_colorscale(colors, scale=None, colorscale=None):
406409 list, it must be the same legnth as colors and must contain all floats
407410 For documentation regarding to the form of the output, see
408411 https://plot.ly/python/reference/#mesh3d-colorscale
412+
413+ :param (list) colors: a list of single colors
409414 """
410415 if colorscale is None :
411416 colorscale = []
0 commit comments